Bug 231 - Sudo skips some non-blank characters in the do_syslog()
Sudo skips some non-blank characters in the do_syslog()
Status: RESOLVED FIXED
Product: Sudo
Classification: Unclassified
Component: Sudo
1.6.8
PC All
: low normal
Assigned To: Todd C. Miller
http://codelabs.ru/patches/sudo/patch...
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-12-22 10:36 MST by Eygene Ryabinkin
Modified: 2007-06-14 11:56 MDT (History)
0 users

See Also:


Attachments
Patch, first version (320 bytes, patch)
2006-12-23 16:46 MST, Eygene Ryabinkin
Details | Diff
Patch, second version (2.28 KB, patch)
2006-12-23 16:57 MST, Eygene Ryabinkin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eygene Ryabinkin 2006-12-22 10:36:22 MST
While reading sudo's logging.c sources I've found that the famous piece of code

            /* Eliminate leading whitespace */
            for ( p = tmp; *p != ' ' && *p !='\0'; p++ )
                ;

in the logging.c:do_syslog() contradicts with its own comment: it eliminates non-whitespace characters, i.e. stops on the first space or '\0'. I think that it contradicts with the original idea -- it should really skip the whitespace. So the for loop should look like
            for (p = tmp; *p == ' '; p++)
                ;

The patch is on the provided URL.
Comment 1 Eygene Ryabinkin 2006-12-23 16:46:24 MST
Created attachment 47 [details]
Patch, first version
Comment 2 Eygene Ryabinkin 2006-12-23 16:53:09 MST
Looking into do_syslog() more carefully, I've found another problems.
1. If buffer size to be logged is a multiple of the MAXSYSLOGLEN, then the last chunk will be logged twice.
2. Only buffer size was taken into the consideration, but format string includes more characters, so long commands were truncated.
The patch that fixes these two bugs and the previous one is attached.
Comment 3 Eygene Ryabinkin 2006-12-23 16:57:28 MST
Created attachment 48 [details]
Patch, second version

Second version of the patch.
Comment 4 Todd C. Miller 2007-06-14 11:56:13 MDT
I had thought that the MAXSYSLOGLEN number I was using had enough breathing room to hold the continuation text but apparently not.  An adaptation of your patch will appear in sudo 1.6.9.