From 21796e671ab5c352ccefcd5bf6e054dcd6290472 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 19 Nov 2003 18:04:49 +0000 Subject: [PATCH] Don't assume offsetof(foo,firstelement) is zero --- servers/slapd/controls.c | 4 ++-- servers/slapd/search.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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; -- 2.39.5