cbufferlow-level-code

What does this syntax *((unsigned int *)(buffer+i)) mean in C


This is the code:

char *command, *buffer;

command = (char *) malloc(200);
bzero(command, 200);

strcpy(command, "./notesearch \'");
buffer = command + strlen(command);
for(int i=0; i < 160; i+=4) {
    *((unsigned int *)(buffer+i)) = ret; // What does this syntax mean?
}

You can get the full code here => https://raw.githubusercontent.com/intere/hacking/master/booksrc/exploit_notesearch.c

Please help me I'm a beginner.


Solution

  • Read it from the inner part to the outer. Here we must suppose that buffer is a pointer to some memory area or array element. You have:

    In C, when evaluating expressions, always go from the inside to the outer.