summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2014-09-08 12:57:09 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2014-09-08 12:57:09 (GMT)
commit450740f6d60f5919b421f65b873828761e366e67 (patch) (side-by-side diff)
treed176ace8a054821a3ab26b39290e03f70b9ad2dd
parentb2154f3060041a6c71c47a7e65328a66d2214814 (diff)
downloadsmap-450740f6d60f5919b421f65b873828761e366e67.tar.gz
smap-450740f6d60f5919b421f65b873828761e366e67.tar.bz2
ldap: bugfix
* modules/ldap/ldap.c (getvar): Don't add extra delimiter at the end of output.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--modules/ldap/ldap.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/modules/ldap/ldap.c b/modules/ldap/ldap.c
index b040820..d686f6b 100644
--- a/modules/ldap/ldap.c
+++ b/modules/ldap/ldap.c
@@ -901,25 +901,36 @@ getvar(const char *var, size_t len, void *data)
memcpy(p, values[0]->bv_val, values[0]->bv_len);
p[values[0]->bv_len] = 0;
} else {
- size_t i, len = 0, dlen = strlen(gd->joinstr);
+ size_t i, len, dlen = strlen(gd->joinstr);
char *q;
- for (i = 0; values[i]; i++)
+ len = values[0]->bv_len;
+ for (i = 1; values[i]; i++)
len += values[i]->bv_len + dlen;
+ smap_debug(dbgid, 2, ("%s: %lu", var, (unsigned long)i));
p = malloc(len + 1);
if (!p)
return NULL;
q = p;
for (i = 0; values[i]; i++) {
+ smap_debug(dbgid, 2,
+ ("%s: %lu=%*.*s", var,
+ (unsigned long)i,
+ (int)values[i]->bv_len,
+ (int)values[i]->bv_len,
+ values[i]->bv_val));
+ if (i) {
+ memcpy(q, gd->joinstr, dlen);
+ q += dlen;
+ }
memcpy(q, values[i]->bv_val,
values[i]->bv_len);
q += values[i]->bv_len;
- memcpy(q, gd->joinstr, dlen);
- q += dlen;
}
*q = 0;
}
- smap_debug(dbgid, 1, ("attr %*.*s=%s", (int)len, (int)len, var, p));
+ smap_debug(dbgid, 1, ("attr %*.*s=%s",
+ (int)len, (int)len, var, p));
ldap_value_free_len(values);
return p;
}

Return to:

Send suggestions and report system problems to the System administrator.