Hi i tried netsnmpd from net/net-snmp today and run into a problem with the default config where the daemon crashed while starting.
It seemed to be an off-by-one related to file based logging which already got fixed upstream [0]. netsnmpd started after applying the patch from upstream. [0] https://sourceforge.net/p/net-snmp/code/ci/c890caa47876a0da05e69cae1428b65d9ec70478/ Cheers, Fabian diff --git a/net/net-snmp/patches/patch-snmplib_snmp_logging_c b/net/net-snmp/patches/patch-snmplib_snmp_logging_c new file mode 100644 index 00000000000..d9497c859b7 --- /dev/null +++ b/net/net-snmp/patches/patch-snmplib_snmp_logging_c @@ -0,0 +1,30 @@ +$OpenBSD$ + +Avoid off-by-one error when logging "" to a file + +Upstream commit https://sourceforge.net/p/net-snmp/code/ci/c890caa47876a0da05e69cae1428b65d9ec70478/ + +Index: snmplib/snmp_logging.c +--- snmplib/snmp_logging.c.orig ++++ snmplib/snmp_logging.c +@@ -1254,6 +1254,7 @@ log_handler_file( netsnmp_log_handler* logh, int pr + { + FILE *fhandle; + char sbuf[40]; ++ int len = strlen( str ); + + /* + * We use imagic to save information about whether the next output +@@ -1282,7 +1283,11 @@ log_handler_file( netsnmp_log_handler* logh, int pr + } + fprintf(fhandle, "%s%s", sbuf, str); + fflush(fhandle); +- logh->imagic = str[strlen(str) - 1] == '\n'; ++ if (len > 0) { ++ logh->imagic = str[strlen(str) - 1] == '\n'; ++ } else { ++ logh->imagic = 0; ++ } + return 1; + } + #endif /* NETSNMP_FEATURE_REMOVE_LOGGING_FILE */
diff --git a/net/net-snmp/patches/patch-snmplib_snmp_logging_c b/net/net-snmp/patches/patch-snmplib_snmp_logging_c new file mode 100644 index 00000000000..d9497c859b7 --- /dev/null +++ b/net/net-snmp/patches/patch-snmplib_snmp_logging_c @@ -0,0 +1,30 @@ +$OpenBSD$ + +Avoid off-by-one error when logging "" to a file + +Upstream commit https://sourceforge.net/p/net-snmp/code/ci/c890caa47876a0da05e69cae1428b65d9ec70478/ + +Index: snmplib/snmp_logging.c +--- snmplib/snmp_logging.c.orig ++++ snmplib/snmp_logging.c +@@ -1254,6 +1254,7 @@ log_handler_file( netsnmp_log_handler* logh, int pr + { + FILE *fhandle; + char sbuf[40]; ++ int len = strlen( str ); + + /* + * We use imagic to save information about whether the next output +@@ -1282,7 +1283,11 @@ log_handler_file( netsnmp_log_handler* logh, int pr + } + fprintf(fhandle, "%s%s", sbuf, str); + fflush(fhandle); +- logh->imagic = str[strlen(str) - 1] == '\n'; ++ if (len > 0) { ++ logh->imagic = str[strlen(str) - 1] == '\n'; ++ } else { ++ logh->imagic = 0; ++ } + return 1; + } + #endif /* NETSNMP_FEATURE_REMOVE_LOGGING_FILE */