From: chip Date: Fri, 25 Jul 2003 01:53:03 +0000 (+0000) Subject: * support/nfs/xlog.c (xlog): Revise buffer-overflow fix to X-Git-Tag: nfs-utils-1-0-5-post1~4 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=4fa9424a6c71f113d08e2bb1bdc7adab32d6a23a;p=nfs-utils.git * support/nfs/xlog.c (xlog): Revise buffer-overflow fix to use Debian security team's cleaner approach. --- diff --git a/ChangeLog b/ChangeLog index 11582bd..823d178 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2003-07-24 Chip Salzenberg + * 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. diff --git a/support/nfs/xlog.c b/support/nfs/xlog.c index c4e7ea1..b06d12e 100644 --- a/support/nfs/xlog.c +++ b/support/nfs/xlog.c @@ -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 } }