int len;
int *i;
void **p;
- char *s, **b;
+ char *s, **b, **ps;
char c;
const uint8 *buf0 = buf;
const char *fmt0 = fmt;
int bufsize0 = bufsize;
va_start(ap, fmt);
-
+
while (*fmt) {
switch ((c=*fmt++)) {
case 'b':
p = va_arg(ap, void **);
if (bufsize < len)
goto no_space;
- /*
+ /*
* This isn't a real pointer - only a token (1 or 0)
* to mark the fact a pointer is present.
*/
*p = (void *)(IVAL(buf, 0) ? (void *)1 : NULL);
break;
case 'P':
- s = va_arg(ap,char *);
+ /* Return malloc'ed string. */
+ ps = va_arg(ap,char **);
len = strlen((const char *)buf) + 1;
- if (bufsize < len || len > sizeof(pstring))
- goto no_space;
- memcpy(s, buf, len);
+ *ps = SMB_STRDUP((const char *)buf);
break;
case 'f':
s = va_arg(ap,char *);
memcpy(*b, buf+4, *i);
break;
default:
- DEBUG(0,("Unknown tdb_unpack format %c in %s\n",
+ DEBUG(0,("Unknown tdb_unpack format %c in %s\n",
c, fmt));
len = 0;
va_end(ap);
- DEBUG(18,("tdb_unpack(%s, %d) -> %d\n",
+ DEBUG(18,("tdb_unpack(%s, %d) -> %d\n",
fmt0, bufsize0, (int)PTR_DIFF(buf, buf0)));
return PTR_DIFF(buf, buf0);
va_start(ap, format);
vasprintf(&ptr, format, ap);
va_end(ap);
-
+
if (!ptr || !*ptr)
return;
TRUSTED_DOM_PASS* pass)
{
int idx, len = 0;
+ char *passp = NULL;
if (!pack_buf || !pass) return -1;
&pass->uni_name[idx]);
len += tdb_unpack(pack_buf + len, bufsize - len, "dPd",
- &pass->pass_len, &pass->pass, &pass->mod_time);
+ &pass->pass_len, &passp, &pass->mod_time);
+ if (passp) {
+ fstrcpy(pass->pass, passp);
+ }
+ SAFE_FREE(passp);
/* unpack domain sid */
len += tdb_sid_unpack(pack_buf + len, bufsize - len,
TDB_DATA kbuf, dbuf;
fstring printername;
char adevice[MAXDEVICENAME];
+ char *comment = NULL;
kbuf = make_printer_tdbkey(talloc_tos(), sharename);
info->sharename,
info->portname,
info->drivername,
- info->comment,
+ &comment,
info->location,
info->sepfile,
info->printprocessor,
info->datatype,
info->parameters);
+ if (comment) {
+ strlcpy(info->comment, comment, sizeof(info->comment));
+ SAFE_FREE(comment);
+ }
+
/* Samba has to have shared raw drivers. */
info->attributes |= PRINTER_ATTRIBUTE_SAMBA;
info->attributes &= ~PRINTER_ATTRIBUTE_NOT_SAMBA;
DATA_BLOB *data)
{
fstring sharename;
- pstring lpqcommand, lprmcommand;
+ char *lpqcommand = NULL, *lprmcommand = NULL;
int printing_type;
size_t len;
len = tdb_unpack( (uint8 *)data->data, data->length, "fdPP",
sharename,
&printing_type,
- lpqcommand,
- lprmcommand );
+ &lpqcommand,
+ &lprmcommand );
if ( len == -1 ) {
+ SAFE_FREE(lpqcommand);
+ SAFE_FREE(lprmcommand);
DEBUG(0,("print_queue_receive: Got invalid print queue update message\n"));
return;
}
get_printer_fns_from_type((enum printing_types)printing_type),
lpqcommand, lprmcommand );
+ SAFE_FREE(lpqcommand);
+ SAFE_FREE(lprmcommand);
return;
}