diff options
author | Sami Kerola | 2012-07-08 21:03:14 +0200 |
---|---|---|
committer | Karel Zak | 2012-07-10 08:56:22 +0200 |
commit | e31926b4434a4df877745039809705361d1c79e8 (patch) | |
tree | 973aa0c66b9a9c4f963506214f4a5a8357c3572e /login-utils/utmpdump.c | |
parent | fix buffer overrun in some calls to sscanf (diff) | |
download | kernel-qcow2-util-linux-e31926b4434a4df877745039809705361d1c79e8.tar.gz kernel-qcow2-util-linux-e31926b4434a4df877745039809705361d1c79e8.tar.xz kernel-qcow2-util-linux-e31926b4434a4df877745039809705361d1c79e8.zip |
utmpdump: fixes based on static analysis [cppcheck]
[utmpdump.c:82]: (style) The function 'unspace' is never used
[utmpdump.c:131]: (style) The scope of the variable 't' can be reduced
[utmpdump.c:167]: (warning) scanf without field width limits can crash with huge input data
[kzak@redhat.com: - don't use scanf field width limits for integers]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils/utmpdump.c')
-rw-r--r-- | login-utils/utmpdump.c | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/login-utils/utmpdump.c b/login-utils/utmpdump.c index a525ad135..6c0751d57 100644 --- a/login-utils/utmpdump.c +++ b/login-utils/utmpdump.c @@ -79,15 +79,6 @@ static void xcleanse(char *s, int len) *s = '?'; } -static void unspace(char *s, int len) -{ - while (*s && *s != ' ' && len--) - ++s; - - if (len > 0) - *s = '\0'; -} - static void print_utline(struct utmp ut) { char *addr_string, *time_string; @@ -128,7 +119,6 @@ static void dump(FILE *fp, int forever) static int gettok(char *line, char *dest, int size, int eatspace) { int bpos, epos, eaten; - char *t; bpos = strchr(line, '[') - line; if (bpos < 0) @@ -143,6 +133,7 @@ static int gettok(char *line, char *dest, int size, int eatspace) eaten = bpos + epos + 1; if (eatspace) { + char *t; if ((t = strchr(line, ' '))) *t = 0; } |