commit-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_2-62-g485bcb


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_2-62-g485bcb2
Date: Wed, 08 Apr 2015 18:45:01 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  485bcb20768a867c3f06b912634f658d8b934dde (commit)
      from  434c5ce5e0242af677e44e31fb7e39e9d832bc91 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=485bcb20768a867c3f06b912634f658d8b934dde


commit 485bcb20768a867c3f06b912634f658d8b934dde
Author: Mats Erik Andersson <address@hidden>
Date:   Wed Apr 8 19:05:36 2015 +0200

    syslogd: Overlapping string locations.
    
    A configuration line with leading white space is copied
    into an overlapping location with insufficient care.

diff --git a/ChangeLog b/ChangeLog
index 7a3dde8..8e58e57 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2015-04-08  Mats Erik Andersson  <address@hidden>
+
+       syslogd: Overlapping string locations.
+       Configuration lines with leading white space are normalized
+       by copying a string to an overlapping location.  Issue found
+       by Alex Kost and reported to us in
+       http://lists.gnu.org/archive/html/bug-inetutils/2015-04/msg00001.html
+
+       * src/syslogd.c (load_conffile): Declare P in smallest
+       possible code block.  Use `memmove' instead of `strcpy'
+       to neutralize the effects of overlapping locations.
+
+       * tests/syslogd.sh: Add a new test case, checking resistance
+       to leading white space and wrapped lines in configuration file.
+       (OUT_NOTICE, COUNT_NOTICE, wrapped, COUNT_WRAP): New variables.
+
 2015-04-02  Mats Erik Andersson  <address@hidden>
 
        Testing of inetd service.
diff --git a/src/syslogd.c b/src/syslogd.c
index c1280e9..0fa4194 100644
--- a/src/syslogd.c
+++ b/src/syslogd.c
@@ -1837,7 +1837,6 @@ load_conffile (const char *filename, struct filed **nextp)
 {
   FILE *cf;
   struct filed *f;
-  char *p;
 #ifndef LINE_MAX
 # define LINE_MAX 2048
 #endif
@@ -1896,6 +1895,7 @@ load_conffile (const char *filename, struct filed **nextp)
      - deal with continuation lines, last char is '\' .  */
   while (fgets (cline, line_max - (cline - cbuf), cf) != NULL)
     {
+      char *p;
       size_t len = strlen (cline);
 
       /* If this is a continuation line, skip leading whitespace for
@@ -1989,7 +1989,7 @@ load_conffile (const char *filename, struct filed **nextp)
       if (*p == '\0' || *p == '#')
        continue;
 
-      strcpy (cline, p);
+      memmove (cline, p, strlen (p) + 1);
 
       /* Cut the trailing spaces.  */
       for (p = strchr (cline, '\0'); isspace (*--p);)
diff --git a/tests/syslogd.sh b/tests/syslogd.sh
index a0c2e9d..0ba984d 100755
--- a/tests/syslogd.sh
+++ b/tests/syslogd.sh
@@ -144,6 +144,7 @@ CONF="$IU_TESTDIR"/syslog.conf
 CONFD="$IU_TESTDIR"/syslog.d
 PID="$IU_TESTDIR"/syslogd.pid
 OUT="$IU_TESTDIR"/messages
+OUT_NOTICE="$IU_TESTDIR"/notice
 : ${SOCKET:=$IU_TESTDIR/log}
 
 mkdir -p "$CONFD"
@@ -277,7 +278,7 @@ fi
 TAG="syslogd-test"
 
 # Remove old files in use by daemon.
-rm -f "$OUT" "$PID" "$CONF"
+rm -f "$OUT" "$OUT_NOTICE" "$PID" "$CONF"
 
 # Full testing at the standard port needs a superuser.
 # Randomise if necessary to get an underprivileged port.
@@ -312,6 +313,9 @@ fi
 #
 cat > "$CONF" <<-EOT
        *.*     $OUT
+       # Test the removal of leading blanks and correct line wrapping.
+            *.notice \\
+          $OUT_NOTICE
        # Empty priority and action.
        12345
        # Missing action.
@@ -420,6 +424,11 @@ if $do_unix_socket; then
     TESTCASES=`expr $TESTCASES + 1`
     $LOGGER -h "$SOCKET" -p user.info -t "$TAG" \
        "Sending BSD message. (pid $$)"
+
+    # Presence is checked in $OUT and $OUT_NOTICE, so merit value is 2.
+    TESTCASES=`expr $TESTCASES + 2`
+    $LOGGER -h "$SOCKET" -p daemon.notice -t "$TAG" \
+       "Attemping to locate wrapped configuration. (pid $$)"
 fi
 
 if $do_socket_length; then
@@ -571,6 +580,14 @@ sleep 3
 # Initial message logging.
 COUNT=`$GREP -c "$TAG" "$OUT"`
 
+# All notices in $OUT_NOTICE should be present also in $OUT.
+# Assign value 1 to full outcome.
+COUNT_NOTICE=`$SED -n '$=' "$OUT_NOTICE"`
+wrapped=`$GREP -c -f "$OUT_NOTICE" "$OUT"`
+
+COUNT_WRAP=0
+test $COUNT_NOTICE -ne $wrapped || COUNT_WRAP=1
+
 # Second set-up after SIGHUP.
 COUNT2=`$GREP -c "$TAG2" "$OUT_USER"`
 COUNT3=`$GREP -c "$TAG2" "$OUT_DEBUG"`
@@ -597,7 +614,7 @@ COUNT5_user=`$GREP -c "$TAG2.*user" "$OUT_LOCAL0"`
 COUNT5_local=`cat "$OUT_USER" "$OUT_UNOTICE" "$OUT_DEBUG" | \
              $GREP -c "$TAG2.*local0"`
 
-SUCCESSES=`expr $SUCCESSES + $COUNT \
+SUCCESSES=`expr $SUCCESSES + $COUNT + $COUNT_WRAP \
                + 2 \* $COUNT2 - $COUNT2_debug \
                + 2 \* $COUNT3 - $COUNT3_info \
                + 2 \* $COUNT4 - $COUNT4_notice - $COUNT4_illegal \
@@ -611,6 +628,8 @@ if [ -n "${VERBOSE+yes}" ]; then
                          "$OUT_LOCAL0"`
        ---------- Full message log for syslogd. ------------
        `cat "$OUT"`
+       ---------- Notices during first stage. --------------
+       `cat "$OUT_NOTICE"`
        ---------- User notice message log. -----------------
        `cat "$OUT_UNOTICE"`
        ---------- User info message log. -------------------

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog        |   16 ++++++++++++++++
 src/syslogd.c    |    4 ++--
 tests/syslogd.sh |   23 +++++++++++++++++++++--
 3 files changed, 39 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]