/*
Bacula® - The Network Backup Solution
- Copyright (C) 2005-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2005-2012 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
This program is Free Software; you can redistribute it and/or
- modify it under the terms of version two of the GNU General Public
+ modify it under the terms of version three of the GNU Affero General Public
License as published by the Free Software Foundation and included
in the file LICENSE.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
- You should have received a copy of the GNU General Public License
+ You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
#define DP_C_LDOUBLE 3
#define DP_C_INT64 4
#define DP_C_WCHAR 5 /* wide characters */
+#define DP_C_SIZE_T 6
#define char_to_int(p) ((p)- '0')
#undef MAX
ch = *format++;
}
break;
+ case 'z':
+ cflags = DP_C_SIZE_T;
+ ch = *format++;
+ break;
case 'L':
cflags = DP_C_LDOUBLE;
ch = *format++;
value = va_arg(args, int32_t);
} else if (cflags == DP_C_INT64) {
value = va_arg(args, int64_t);
+ } else if (cflags == DP_C_SIZE_T) {
+ value = va_arg(args, ssize_t);
} else {
value = va_arg(args, int);
}
value = va_arg(args, uint32_t);
} else if (cflags == DP_C_INT64) {
value = va_arg(args, uint64_t);
+ } else if (cflags == DP_C_SIZE_T) {
+ value = va_arg(args, size_t);
} else {
value = va_arg(args, unsigned int);
}
case 's':
if (cflags != DP_C_WCHAR) {
strvalue = va_arg(args, char *);
+ if (!strvalue) {
+ strvalue = (char *)"<NULL>";
+ }
currlen = fmtstr(buffer, currlen, maxlen, strvalue, flags, min, max);
} else {
/* %ls means to edit wide characters */
wstrvalue = va_arg(args, wchar_t *);
+ if (!wstrvalue) {
+ wstrvalue = (wchar_t *)L"<NULL>";
+ }
currlen = fmtwstr(buffer, currlen, maxlen, wstrvalue, flags, min, max);
}
break;
}
currlen = fmtint(buffer, currlen, maxlen, value, 16, min, max, flags);
break;
+
+#ifdef SECURITY_PROBLEM
case 'n':
if (cflags == DP_C_INT16) {
int16_t *num;
num = va_arg(args, int16_t *);
-#ifdef SECURITY_PROBLEM
*num = currlen;
-#endif
} else if (cflags == DP_C_INT32) {
int32_t *num;
num = va_arg(args, int32_t *);
-#ifdef SECURITY_PROBLEM
*num = (int32_t)currlen;
-#endif
} else if (cflags == DP_C_INT64) {
int64_t *num;
num = va_arg(args, int64_t *);
-#ifdef SECURITY_PROBLEM
*num = (int64_t)currlen;
-#endif
} else {
int32_t *num;
num = va_arg(args, int32_t *);
-#ifdef SECURITY_PROBLEM
*num = (int32_t)currlen;
-#endif
}
break;
+#endif
case '%':
outch(ch);
break;
} else if (max < 0) {
max = maxlen;
}
- if (!value) {
- value = "<NULL>";
- }
strln = strlen(value);
if (strln > max) {
strln = max; /* truncate to max */
} else if (max < 0) {
max = maxlen;
}
- if (!value) {
- value = L"<NULL>";
- }
strln = wcslen(value);
if (strln > max) {
strln = max; /* truncate to max */
if (!result) {
r_length = 0;
+ dummy[0] = 0;
result = dummy;
} else {
r_length = strlen(result);