]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/aclparse.c
silence warning
[openldap] / servers / slapd / aclparse.c
index 7a1b43314d242f29d1c19c0fa2929644034a6c5b..b433196837ff97e3894c0955a64c4d5c62212de3 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2010 The OpenLDAP Foundation.
+ * Copyright 1998-2011 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -2538,7 +2538,7 @@ str2access( const char *str )
 static char *
 safe_strncopy( char *ptr, const char *src, size_t n, struct berval *buf )
 {
-       while ( &ptr[n] >= &buf->bv_val[buf->bv_len] ) {
+       while ( ptr + n >= buf->bv_val + buf->bv_len ) {
                char *tmp = ch_realloc( buf->bv_val, 2*buf->bv_len );
                if ( tmp == NULL ) {
                        return NULL;
@@ -2782,10 +2782,9 @@ acl_unparse( AccessControl *a, struct berval *bv )
                aclbuf.bv_len = ACLBUF_CHUNKSIZE;
        }
 
-       bv->bv_val = aclbuf.bv_val;
        bv->bv_len = 0;
 
-       ptr = bv->bv_val;
+       ptr = aclbuf.bv_val;
 
        ptr = acl_safe_strcopy( ptr, "to" );
        if ( !BER_BVISNULL( &a->acl_dn_pat ) ) {
@@ -2853,6 +2852,7 @@ acl_unparse( AccessControl *a, struct berval *bv )
                ptr = access2text( b, ptr );
        }
        *ptr = '\0';
+       bv->bv_val = aclbuf.bv_val;
        bv->bv_len = ptr - bv->bv_val;
 }