*
* Adapted for Bacula -- note there were lots of bugs in
* the original code: %lld and %s were seriously broken, and
- * with FP turned off %f seg faults.
+ * with FP turned off %f seg faulted.
+ *
* Kern Sibbald, November MMV
*
* Version $Id$
*/
+/*
+ Bacula® - The Network Backup Solution
+
+ Copyright (C) 2005-2006 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
+ License as published by the Free Software Foundation plus additions
+ that are listed in the file LICENSE.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ 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
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+ Bacula® is a registered trademark of John Walker.
+ The licensor of Bacula is the Free Software Foundation Europe
+ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+ Switzerland, email:ftf@fsfeurope.org.
+*/
+
#include "bacula.h"
#define FP_OUTPUT 1 /* Bacula uses floating point */
-
-/*
- Temp only for me -- NOT YET READY FOR USE -- seems to work fine
- on Linux, but doesn't build correctly on Win32
+/* Define the following if you want all the features of
+ * normal printf, but with all the security problems.
+ * For Bacula we turn this off, and it silently ignores
+ * formats that could pose a security problem.
*/
+#undef SECURITY_PROBLEM
+
#ifdef USE_BSNPRINTF
#ifdef HAVE_LONG_DOUBLE
#define DP_C_INT64 4
#define char_to_int(p) ((p)- '0')
+#undef MAX
#define MAX(p,q) (((p) >= (q)) ? (p) : (q))
/*
int cflags;
int32_t currlen;
int base;
- int junk;
#ifdef FP_OUTPUT
LDOUBLE fvalue;
#endif
min = 10 * min + char_to_int(ch);
ch = *format++;
} else if (ch == '*') {
-#ifdef SECURITY_PROBLEM
min = va_arg(args, int);
-#else
- junk = va_arg(args, int);
-#endif
ch = *format++;
state = DP_S_DOT;
} else
max = 10 * max + char_to_int(ch);
ch = *format++;
} else if (ch == '*') {
-#ifdef SECURITY_PROBLEM
max = va_arg(args, int);
-#else
- junk = va_arg(args, int);
-#endif
ch = *format++;
state = DP_S_MOD;
} else
cflags = DP_C_LDOUBLE;
ch = *format++;
break;
+ case 'q': /* same as long long */
+ cflags = DP_C_INT64;
+ ch = *format++;
+ break;
default:
break;
}
if (cflags == DP_C_INT16) {
value = va_arg(args, uint32_t);
} else if (cflags == DP_C_INT32) {
- value = (long)va_arg(args, uint32_t);
+ value = va_arg(args, uint32_t);
} else if (cflags == DP_C_INT64) {
- value = (int64_t) va_arg(args, uint64_t);
+ value = va_arg(args, uint64_t);
} else {
- value = (long)va_arg(args, unsigned int);
+ value = va_arg(args, unsigned int);
}
currlen = fmtint(buffer, currlen, maxlen, value, base, min, max, flags);
break;
currlen = fmtstr(buffer, currlen, maxlen, strvalue, flags, min, max);
break;
case 'p':
+ flags |= DP_F_UNSIGNED;
strvalue = va_arg(args, char *);
currlen = fmtint(buffer, currlen, maxlen, (long)strvalue, 16, min, max, flags);
break;