summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2007-12-14 14:47:07 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:50:25 +0100
commit8959ce0ea672a59cada4b39071443cf8cad3ad2d (patch)
tree232974d47fbcde7d387e04dc148df5c820175b7a /source4/lib
parenta94142487add08cd38b6f51b7048c3b50eaef599 (diff)
downloadsamba-8959ce0ea672a59cada4b39071443cf8cad3ad2d.tar.gz
samba-8959ce0ea672a59cada4b39071443cf8cad3ad2d.tar.bz2
samba-8959ce0ea672a59cada4b39071443cf8cad3ad2d.zip
r26457: Janitorial: Don't use pstring in tdb_unpack
(This used to be commit 447bc42180cf0be71a35e40f6d93d91879397a48)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/util/util_tdb.c17
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);