Initial fix for berbuf alignment bug (ITS#2760)

Needs to be applied to other stack allocated berbufs.
This commit is contained in:
Kurt Zeilenga 2003-10-12 04:45:09 +00:00
parent d03c83f077
commit 767cf365ea
4 changed files with 25 additions and 14 deletions

View File

@ -158,6 +158,17 @@ extern char ber_pvt_opt_on;
#define LBER_OPT_ERROR (-1)
#define LBER_ELEMENT_SIZEOF (256) /* must be >= sizeof(BerElement) */
typedef union ber_buffer_u {
char charbuf[LBER_ELEMENT_SIZEOF];
/* force alignment */
int intbuf;
long longbuf;
float floatbuf;
double doublebuf;
char* ptrbuf;
} BerElementBuffer;
typedef struct berelement BerElement;
typedef struct sockbuf Sockbuf;
typedef struct seqorset Seqorset;

View File

@ -83,8 +83,8 @@ int slap_passwd_parse( struct berval *reqdata,
int rc = LDAP_SUCCESS;
ber_tag_t tag;
ber_len_t len;
char berbuf[LBER_ELEMENT_SIZEOF];
BerElement *ber = (BerElement *)berbuf;
BerElementBuffer berbuf;
BerElement *ber = (BerElement *)&berbuf;
if( reqdata == NULL ) {
return LDAP_SUCCESS;
@ -224,9 +224,9 @@ struct berval * slap_passwd_return(
{
int rc;
struct berval *bv = NULL;
char berbuf[LBER_ELEMENT_SIZEOF];
BerElementBuffer berbuf;
/* opaque structure, size unknown but smaller than berbuf */
BerElement *ber = (BerElement *)berbuf;
BerElement *ber = (BerElement *)&berbuf;
assert( cred != NULL );

View File

@ -223,8 +223,8 @@ send_ldap_response(
Operation *op,
SlapReply *rs )
{
char berbuf[LBER_ELEMENT_SIZEOF];
BerElement *ber = (BerElement *)berbuf;
BerElementBuffer berbuf;
BerElement *ber = (BerElement *) &berbuf;
int rc;
long bytes;
@ -602,8 +602,8 @@ slap_send_ldap_intermediate( Operation *op, SlapReply *rs )
int
slap_send_search_entry( Operation *op, SlapReply *rs )
{
char berbuf[LBER_ELEMENT_SIZEOF];
BerElement *ber = (BerElement *)berbuf;
BerElementBuffer berbuf;
BerElement *ber = (BerElement *) &berbuf;
Attribute *a, *aa;
int i, j, rc=-1, bytes;
char *edn;
@ -1193,8 +1193,8 @@ error_return:;
int
slap_send_search_reference( Operation *op, SlapReply *rs )
{
char berbuf[LBER_ELEMENT_SIZEOF];
BerElement *ber = (BerElement *)berbuf;
BerElementBuffer berbuf;
BerElement *ber = (BerElement *) &berbuf;
int rc = 0;
int bytes;
void *mark;
@ -1437,8 +1437,8 @@ int slap_read_controls(
{
int rc;
struct berval bv;
char berbuf[LBER_ELEMENT_SIZEOF];
BerElement *ber = (BerElement *) berbuf;
BerElementBuffer berbuf;
BerElement *ber = (BerElement *) &berbuf;
LDAPControl c;
ber_len_t siz, len;
Operation myop;

View File

@ -28,8 +28,8 @@ str2filter_x( Operation *op, const char *str )
{
int rc;
Filter *f = NULL;
char berbuf[LBER_ELEMENT_SIZEOF];
BerElement *ber = (BerElement *)berbuf;
BerElementBuffer berbuf;
BerElement *ber = (BerElement *)&berbuf;
const char *text = NULL;
#ifdef NEW_LOGGING