]> granicus.if.org Git - sudo/commitdiff
removed a bunch of unnecesary strncpy()'s and replaced with strcat()
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 30 Jul 1995 18:38:19 +0000 (18:38 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 30 Jul 1995 18:38:19 +0000 (18:38 +0000)
logging.c

index c4f1b13f6bf39148cab64de445b9b5119ee3b1f3..225e53404ade6e8b2161275de088bb5f9b596ce7 100644 (file)
--- a/logging.c
+++ b/logging.c
@@ -322,6 +322,7 @@ void log_error(code)
        strcat(logline, cmnd);  /* stuff the command into the logline */
        strcat(logline, " ");
 
+       /* XXX - clean up this abonimation and just set count sanely */
        if (Argc > 1) {
            argc = Argc - 2;
            argv = Argv + 1;
@@ -330,22 +331,14 @@ void log_error(code)
            argv = Argv;
        }
 
-       p = logline + strlen(logline);
-       count = (int) (logline + MAXLOGLEN - p);
-
        /*
-        * Now stuff as much of the rest of the line as will fit
-        * Do word wrap if logging to a file.
+        * We have defined MAXLOGLEN to be bigger than argv[] can be
+        * so do not need to do bounds checking.
         */
-       while (count > 0 && argc--) {
-           strncpy(p, *(++argv), count);
-           strcat(p, " ");
-           p += 1 + (count < strlen(*argv) ? count : strlen(*argv));
-           count = (int) (logline + MAXLOGLEN - p);
+       for (count = 0; count < argc; count++) {
+           strcat(logline, argv[count]);
+           strcat(logline, " ");
        }
-       if (count <= 0)         /* if the line is too long, */
-           strcat(p, " ... "); /* add an elipsis to the end */
-
     }
 
 #if (LOGGING & SLOG_SYSLOG)
@@ -359,11 +352,12 @@ void log_error(code)
      * Log the full line, breaking into multiple syslog(3) calls if necesary
      */
     p = &logline[33];                  /* skip past the date and user */
-    for (count=0; count < (strlen(logline) / MAXSYSLOGLEN) + 1; count++) {
+    for (count = 0; count < strlen(logline) / MAXSYSLOGLEN + 1; count++) {
        if (strlen(p) > MAXSYSLOGLEN) {
            /*
             * Break up the line into what will fit on one syslog(3) line
             * Try to break on a word boundary if possible.
+            * XXX - speed this up!
             */
            for (tmp = p + MAXSYSLOGLEN; tmp > p && *tmp != ' '; tmp--)
                ;