From: Kurt Zeilenga Date: Wed, 19 Nov 2003 18:04:49 +0000 (+0000) Subject: Don't assume offsetof(foo,firstelement) is zero X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~426 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=21796e671ab5c352ccefcd5bf6e054dcd6290472;p=openldap Don't assume offsetof(foo,firstelement) is zero --- diff --git a/servers/slapd/controls.c b/servers/slapd/controls.c index 8c445855bc..16a9e3fcdc 100644 --- a/servers/slapd/controls.c +++ b/servers/slapd/controls.c @@ -986,7 +986,7 @@ static int parsePreRead ( } siz = sizeof( AttributeName ); - off = 0; + off = offsetof( AttributeName, an_name ); if ( ber_scanf( ber, "{M}", &an, &siz, off ) == LBER_ERROR ) { rs->sr_text = "preread control: decoding error"; return LDAP_PROTOCOL_ERROR; @@ -1035,7 +1035,7 @@ static int parsePostRead ( } siz = sizeof( AttributeName ); - off = 0; + off = offsetof( AttributeName, an_name ); if ( ber_scanf( ber, "{M}", &an, &siz, off ) == LBER_ERROR ) { rs->sr_text = "postread control: decoding error"; return LDAP_PROTOCOL_ERROR; diff --git a/servers/slapd/search.c b/servers/slapd/search.c index 2fdd461653..0b898a78bb 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -159,7 +159,7 @@ do_search( /* attributes */ siz = sizeof(AttributeName); - off = 0; + off = offsetof(AttributeName,an_name); if ( ber_scanf( op->o_ber, "{M}}", &op->ors_attrs, &siz, off ) == LBER_ERROR ) { send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding attrs error" ); rs->sr_err = SLAPD_DISCONNECT;