X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fsets.c;h=7dc75079478c1998c254f930a5413fa0d2759df3;hb=a26612bc00bacbc660fa4a26466f609a29a1d072;hp=0fdec47ee2b783b10ce554f3c5c74007d8472f67;hpb=1566454e6e9bbd551835e7aac425b1a5286ff54b;p=openldap diff --git a/servers/slapd/sets.c b/servers/slapd/sets.c index 0fdec47ee2..7dc7507947 100644 --- a/servers/slapd/sets.c +++ b/servers/slapd/sets.c @@ -4,16 +4,17 @@ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file */ -#include "portable.h" +#include "portable.h" -#include +#include #include - + #include "slap.h" #include "sets.h" static char **set_join (char **lset, int op, char **rset); -static char **set_chase (SET_GATHER gatherer, void *cookie, char **set, char *attr, int attrlen, int closure); +static char **set_chase (SET_GATHER gatherer, + void *cookie, char **set, char *attr, int attrlen, int closure); static int set_samedn (char *dn1, char *dn2); long @@ -119,7 +120,8 @@ set_join (char **lset, int op, char **rset) } static char ** -set_chase (SET_GATHER gatherer, void *cookie, char **set, char *attr, int attrlen, int closure) +set_chase (SET_GATHER gatherer, + void *cookie, char **set, char *attr, int attrlen, int closure) { char **vals, **nset; char attrstr[32]; @@ -135,7 +137,7 @@ set_chase (SET_GATHER gatherer, void *cookie, char **set, char *attr, int attrle set_dispose(set); return(NULL); } - memcpy(attrstr, attr, attrlen); + AC_MEMCPY(attrstr, attr, attrlen); attrstr[attrlen] = 0; nset = ch_calloc(1, sizeof(char *)); @@ -195,14 +197,19 @@ set_samedn (char *dn1, char *dn2) } int -set_filter (SET_GATHER gatherer, void *cookie, char *filter, char *user, char *this, char ***results) +set_filter (SET_GATHER gatherer, + void *cookie, char *filter, char *user, char *this, char ***results) { - #define IS_SET(x) ( (long)(x) >= 256 ) - #define IS_OP(x) ( (long)(x) < 256 ) - #define SF_ERROR(x) { rc = -1; goto _error; } - #define SF_TOP() (char **)( (stp < 0) ? 0 : stack[stp] ) - #define SF_POP() (char **)( (stp < 0) ? 0 : stack[stp--] ) - #define SF_PUSH(x) { if (stp >= 63) SF_ERROR(overflow); stack[++stp] = (char **)(long)(x); } +#define IS_SET(x) ( (long)(x) >= 256 ) +#define IS_OP(x) ( (long)(x) < 256 ) +#define SF_ERROR(x) do { rc = -1; goto _error; } while (0) +#define SF_TOP() ( (char **)( (stp < 0) ? 0 : stack[stp] ) ) +#define SF_POP() ( (char **)( (stp < 0) ? 0 : stack[stp--] ) ) +#define SF_PUSH(x) do { \ + if (stp >= 63) SF_ERROR(overflow); \ + stack[++stp] = (char **)(long)(x); \ + } while (0) + char c; char **set, **lset; int len, op, rc, stp; @@ -287,7 +294,7 @@ set_filter (SET_GATHER gatherer, void *cookie, char *filter, char *user, char *t *set = ch_calloc(len + 1, sizeof(char)); if (*set == NULL) SF_ERROR(memory); - memcpy(*set, &filter[-len - 1], len); + AC_MEMCPY(*set, &filter[-len - 1], len); SF_PUSH(set); set = NULL; break; @@ -345,7 +352,8 @@ set_filter (SET_GATHER gatherer, void *cookie, char *filter, char *user, char *t SF_ERROR(syntax); } else { SF_POP(); - set = set_chase(gatherer, cookie, SF_POP(), filter, len, c == '*'); + set = set_chase(gatherer, + cookie, SF_POP(), filter, len, c == '*'); if (set == NULL) SF_ERROR(memory); if (c == '*')