diff options
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/util/util_tdb.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/source4/lib/util/util_tdb.c b/source4/lib/util/util_tdb.c index d7bddbde01..77ad4eb617 100644 --- a/source4/lib/util/util_tdb.c +++ b/source4/lib/util/util_tdb.c @@ -445,7 +445,7 @@ int tdb_unpack(TDB_CONTEXT *tdb, char *buf, int bufsize, const char *fmt, ...) int len; int *i; void **p; - char *s, **b; + char *s, **b, **ps; char c; char *buf0 = buf; const char *fmt0 = fmt; @@ -453,7 +453,7 @@ int tdb_unpack(TDB_CONTEXT *tdb, char *buf, int bufsize, const char *fmt, ...) tdb_log_func log_fn = tdb_log_fn(tdb); va_start(ap, fmt); - + while (*fmt) { switch ((c=*fmt++)) { case 'b': @@ -485,11 +485,10 @@ int tdb_unpack(TDB_CONTEXT *tdb, char *buf, int bufsize, const char *fmt, ...) *p = (void *)IVAL(buf, 0); break; case 'P': - s = va_arg(ap,char *); - len = strlen(buf) + 1; - if (bufsize < len || len > sizeof(pstring)) - goto no_space; - memcpy(s, buf, len); + /* Return a malloc'ed string. */ + ps = va_arg(ap,char ** ); + len = strlen((const char *)buf) + 1; + *ps = strdup((const char *)buf); break; case 'f': s = va_arg(ap,char *); @@ -518,7 +517,7 @@ int tdb_unpack(TDB_CONTEXT *tdb, char *buf, int bufsize, const char *fmt, ...) memcpy(*b, buf+4, *i); break; default: - log_fn(tdb, 0, "Unknown tdb_unpack format %c in %s\n", + log_fn(tdb, 0, "Unknown tdb_unpack format %c in %s\n", c, fmt); len = 0; @@ -531,7 +530,7 @@ int tdb_unpack(TDB_CONTEXT *tdb, char *buf, int bufsize, const char *fmt, ...) va_end(ap); - log_fn(tdb, 18, "tdb_unpack(%s, %d) -> %d\n", + log_fn(tdb, 18, "tdb_unpack(%s, %d) -> %d\n", fmt0, bufsize0, (int)PTR_DIFF(buf, buf0)); return PTR_DIFF(buf, buf0); |