Question

I was taking a peek at blogs, detailing the vulnerable code of the Heartbeat implementation of OpenSSL.

I found this line:

unsigned char *P = &s->s3->rrec.data[0], *p1;

What i do not understand is how is this pointer *p, assigned two different values? The one is:

&s->s3->rrec.data[0]  (also, why is he referencing s?)

and the other is

*p1

How come this pointer get assigned two different values?

Was it helpful?

Solution

The following statement

unsigned char *P = &s->s3->rrec.data[0], *p1;

equals

unsigned char *P = &s->s3->rrec.data[0];
unsigned char *p1;

this further equals

unsigned char *P;
unsigned char *p1;
P = &s->s3->rrec.data[0];

And in C, &s->s3->rrec.data[0] means taking the address of s->s3->rrec.data[0].

Oh, by the way, unsigned char *P = &s->s3->rrec.data[0]; is a definition and initialization of pointer variable P, there is no assignment in it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top