#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int limit, c;
int getebp()
{
__asm__("movl %ebp, %eax");
}
int proc(char *nombre)
{
int *i;
char buffer[256];
i = (int *) getebp(); /* obtiene la dirección de EBP */
limit = *i - (int)buffer + 4; /* se calcula la distancia entre el buffer y EBP y se le suma 4 <- BUG) */
for (c = 0; c < limit && nombre[c] != \'\\0\'; c++)
buffer[c] = nombre[c];
printf("\\nEncantado de conocerte: %s\\n", buffer);
return 0;
}
int main(int argc, char *argv[])
{
if (argc < 2) {
fprintf(stderr, "\\nUso: %s \\n", argv[0]);
exit(0);
}
proc(argv[1]);
return 0;
}