문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top