]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
* 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 11582bda440bfc395ff5dfe7ba8503ebb8cf3354..823d17845f57f1af90d7ebee8e95ccc3a96171e9 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 c4e7ea1d4d6a4cbb51e544d999c86c998ef972fa..b06d12eb23edc62f2dc34c2599f7c4007f7a9bcb 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
                }
        }