summaryrefslogtreecommitdiff
path: root/usr.sbin/snmpd
diff options
context:
space:
mode:
authorMartijn van Duren <martijn@cvs.openbsd.org>2024-02-20 12:41:14 +0000
committerMartijn van Duren <martijn@cvs.openbsd.org>2024-02-20 12:41:14 +0000
commit464de11b289812f68482199dd1222343458bba26 (patch)
tree12ce7b4f44bfe1ae26724ad45c33641fb956d43c /usr.sbin/snmpd
parentca3bcca4b7e089cbc50c114e2d8cf0af15f7c54e (diff)
strptime() only touches the fields specified in the format string,
meaning there could be garbage left in the other fields. Somehow this only caused issues in mktime() when /etc/localtime is set to GMT. Initialize tm to 0. While here fix a type-O in the format string and make the invalid strlen for LAST-UPDATED message more consistent with the other 2 error messages. Found by and OK sthen@
Diffstat (limited to 'usr.sbin/snmpd')
-rw-r--r--usr.sbin/snmpd/mib.y8
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.sbin/snmpd/mib.y b/usr.sbin/snmpd/mib.y
index 5e18dbecc3b..ae33b64280f 100644
--- a/usr.sbin/snmpd/mib.y
+++ b/usr.sbin/snmpd/mib.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: mib.y,v 1.1 2024/01/27 09:53:59 martijn Exp $ */
+/* $OpenBSD: mib.y,v 1.2 2024/02/20 12:41:13 martijn Exp $ */
/*
* Copyright (c) 2023 Martijn van Duren <martijn@openbsd.org>
@@ -496,7 +496,7 @@ moduleidentity : descriptor MODULEIDENTITY lastupdated
lastupdated : LASTUPDATED TEXT {
char timebuf[14] = "";
- struct tm tm;
+ struct tm tm = {};
size_t len;
if ((len = strlen($2)) == 11)
@@ -505,11 +505,11 @@ lastupdated : LASTUPDATED TEXT {
else if (len == 13)
strlcpy(timebuf, $2, sizeof(timebuf));
else {
- yyerror("Invalid LAST-UPDATED");
+ yyerror("Invalid LAST-UPDATED: %s", $2);
YYERROR;
}
- if (strptime(timebuf, "%Y%M%d%H%MZ", &tm) == NULL) {
+ if (strptime(timebuf, "%Y%m%d%H%MZ", &tm) == NULL) {
yyerror("Invalid LAST-UPDATED: %s", $2);
YYERROR;
}