* support/nfs/xlog.c (xlog): Revise buffer-overflow fix to
authorchip <chip>
Fri, 25 Jul 2003 01:53:03 +0000 (01:53 +0000)
committerchip <chip>
Fri, 25 Jul 2003 01:53:03 +0000 (01:53 +0000)
  use Debian security team's cleaner approach.

ChangeLog
support/nfs/xlog.c

index 11582bd..823d178 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2003-07-24  Chip Salzenberg  <chip@pobox.com>
 
+       * support/nfs/xlog.c (xlog): Revise buffer-overflow fix to
+       use Debian security team's cleaner approach.
        * debian/control, debian/*.templates, debian/po/*: Upgrade to
        po-debconf system for translations of debconf messages.
        * debian/changelog: Version 1.0.5-1.
index c4e7ea1..b06d12e 100644 (file)
@@ -142,13 +142,11 @@ xlog(int kind, const char *fmt, ...)
                return;
 
        va_start(args, fmt);
-       vsnprintf(buff, sizeof (buff) - 2, fmt, args);
+       vsnprintf(buff, sizeof (buff), fmt, args);
        va_end(args);
-       buff[sizeof (buff) - 2] = 0;
 
-       if ((n = strlen(buff)) > 0 && buff[n-1] != '\n') {
-               buff[n++] = '\n'; buff[n++] = '\0';
-       }
+       if ((n = strlen(buff)) > 0 && buff[n-1] == '\n')
+               buff[--n] = '\0';
 
        switch (kind) {
        case L_FATAL:
@@ -180,7 +178,7 @@ xlog(int kind, const char *fmt, ...)
                                        tm->tm_year, tm->tm_hour, tm->tm_min,
                                        buff);
 #else
-                       fprintf(log_fp, "%s: %s", log_name, buff);
+                       fprintf(log_fp, "%s: %s\n", log_name, buff);
 #endif
                }
        }