[syslog-ng] [PATCH] str-format: Fix month name parsing in BSD timestamps
Gergely Nagy
algernon at madhouse-project.org
Sat Sep 3 00:39:16 CEST 2011
When parsing the month name in scan_month_abbrev(), use memcmp() in
all cases to compare only the first three chars. Using strcmp() will
always result in us taking the false branch on well-formed timestamps,
as it will scan past the 3-char length.
Signed-off-by: Gergely Nagy <algernon at madhouse-project.org>
---
lib/str-format.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/str-format.c b/lib/str-format.c
index 6c974ba..9011461 100644
--- a/lib/str-format.c
+++ b/lib/str-format.c
@@ -200,19 +200,19 @@ scan_month_abbrev(const gchar **buf, gint *left, gint *mon)
*mon = 7;
break;
case 'S':
- if (strcmp(*buf, "Sep") == 0)
+ if (memcmp(*buf, "Sep", 3) == 0)
*mon = 8;
break;
case 'O':
- if (strcmp(*buf, "Oct") == 0)
+ if (memcmp(*buf, "Oct", 3) == 0)
*mon = 9;
break;
case 'N':
- if (strcmp(*buf, "Nov") == 0)
+ if (memcmp(*buf, "Nov",3 ) == 0)
*mon = 10;
break;
case 'D':
- if (strcmp(*buf, "Dec") == 0)
+ if (memcmp(*buf, "Dec", 3) == 0)
*mon = 11;
break;
default:
--
1.7.5.4
More information about the syslog-ng
mailing list