]> granicus.if.org Git - apache/commitdiff
Fortify complains about an overflow of pad[], which would
authorJeff Trawick <trawick@apache.org>
Thu, 19 Aug 2010 22:35:21 +0000 (22:35 +0000)
committerJeff Trawick <trawick@apache.org>
Thu, 19 Aug 2010 22:35:21 +0000 (22:35 +0000)
require a mongo argv[0].  Get the vprintf formatter to handle
the padding and avoid creating the padding altogether.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@987339 13f79535-47bb-0310-9956-ffa450edef68

server/main.c

index 84a8fe6bc04f06310ea14cf67c899b398ab3ee51..3bd61d4128204a40226d07bf255a3edc3440e78b 100644 (file)
@@ -331,37 +331,32 @@ static process_rec *init_process(int *argc, const char * const * *argv)
 static void usage(process_rec *process)
 {
     const char *bin = process->argv[0];
-    char pad[MAX_STRING_LEN];
-    unsigned i;
-
-    for (i = 0; i < strlen(bin); i++) {
-        pad[i] = ' ';
-    }
-
-    pad[i] = '\0';
+    int pad_len = strlen(bin);
 
     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
                  "Usage: %s [-D name] [-d directory] [-f file]", bin);
 
     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
-                 "       %s [-C \"directive\"] [-c \"directive\"]", pad);
+                 "       %*s [-C \"directive\"] [-c \"directive\"]", pad_len, " ");
 
 #ifdef WIN32
     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
-                 "       %s [-w] [-k start|restart|stop|shutdown] [-n service_name]", pad);
+                 "       %*s [-w] [-k start|restart|stop|shutdown] [-n service_name]",
+                 pad_len, " ");
     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
-                 "       %s [-k install|config|uninstall] [-n service_name]",
-                 pad);
+                 "       %*s [-k install|config|uninstall] [-n service_name]",
+                 pad_len, " ");
 #else
 /* XXX not all MPMs support signalling the server in general or graceful-stop
  * in particular
  */
     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
-                 "       %s [-k start|restart|graceful|graceful-stop|stop]",
-                 pad);
+                 "       %*s [-k start|restart|graceful|graceful-stop|stop]",
+                 pad_len, " ");
 #endif
     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
-                 "       %s [-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X]", pad);
+                 "       %*s [-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X]",
+                 pad_len, " ");
     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
                  "Options:");