]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/bsnprintf.c
ebl add sql_escape to catalog messages
[bacula/bacula] / bacula / src / lib / bsnprintf.c
index 57f556df9d66ed2841112c840df02a4ad64fb5d0..4094e0028357aad9fc70e7c05cd1b27061f1c0eb 100644 (file)
@@ -7,7 +7,8 @@
  *
  * 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$
 
 #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
@@ -109,7 +112,6 @@ int bvsnprintf(char *buffer, int32_t maxlen, const char *format, va_list args)
    int cflags;
    int32_t currlen;
    int base;
-   int junk;
 #ifdef FP_OUTPUT
    LDOUBLE fvalue;
 #endif
@@ -165,11 +167,7 @@ int bvsnprintf(char *buffer, int32_t maxlen, const char *format, va_list args)
             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
@@ -190,11 +188,7 @@ int bvsnprintf(char *buffer, int32_t maxlen, const char *format, va_list args)
             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
@@ -218,6 +212,10 @@ int bvsnprintf(char *buffer, int32_t maxlen, const char *format, va_list args)
             cflags = DP_C_LDOUBLE;
             ch = *format++;
             break;
+         case 'q':                 /* same as long long */
+            cflags = DP_C_INT64;
+            ch = *format++;
+            break;
          default:
             break;
          }