Fix parsing when "file <filename>" directive is used in snmpd.conf

without maxfilesize column.
This commit is contained in:
Jun Kuriyama 2003-12-25 22:44:09 +00:00
parent 25df151652
commit db95497bd3
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=96594
8 changed files with 100 additions and 0 deletions

View File

@ -7,6 +7,7 @@
PORTNAME= net-snmp
PORTVERSION= 5.1
PORTREVISION= 1
CATEGORIES= net ipv6
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= net-snmp

View File

@ -0,0 +1,24 @@
--- agent/mibgroup/ucd-snmp/file.c.orig Thu Dec 25 23:57:14 2003
+++ agent/mibgroup/ucd-snmp/file.c Thu Dec 25 23:57:37 2003
@@ -91,17 +91,19 @@
file_parse_config(const char *token, char *cptr)
{
char space;
+ int items;
if (fileCount < MAXFILE) {
fileTable[fileCount].max = -1;
- sscanf(cptr, "%255s%c%d",
+ memset(fileTable[fileCount].name, 0, sizeof(fileTable[0].name));
+ items = sscanf(cptr, "%255s%c%d",
fileTable[fileCount].name, &space, &fileTable[fileCount].max);
/*
* Log an error then return if the string scanned in was larger then
* it should have been.
*/
- if (space != ' ') {
+ if (items != 1 && space != ' ') {
snmp_log(LOG_ERR, "file_parse_config: file name scanned " \
"in from line %s is too large. fileCount = %d\n", cptr,
fileCount);

View File

@ -7,6 +7,7 @@
PORTNAME= net-snmp
PORTVERSION= 5.1
PORTREVISION= 1
CATEGORIES= net ipv6
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= net-snmp

View File

@ -0,0 +1,24 @@
--- agent/mibgroup/ucd-snmp/file.c.orig Thu Dec 25 23:57:14 2003
+++ agent/mibgroup/ucd-snmp/file.c Thu Dec 25 23:57:37 2003
@@ -91,17 +91,19 @@
file_parse_config(const char *token, char *cptr)
{
char space;
+ int items;
if (fileCount < MAXFILE) {
fileTable[fileCount].max = -1;
- sscanf(cptr, "%255s%c%d",
+ memset(fileTable[fileCount].name, 0, sizeof(fileTable[0].name));
+ items = sscanf(cptr, "%255s%c%d",
fileTable[fileCount].name, &space, &fileTable[fileCount].max);
/*
* Log an error then return if the string scanned in was larger then
* it should have been.
*/
- if (space != ' ') {
+ if (items != 1 && space != ' ') {
snmp_log(LOG_ERR, "file_parse_config: file name scanned " \
"in from line %s is too large. fileCount = %d\n", cptr,
fileCount);

View File

@ -7,6 +7,7 @@
PORTNAME= net-snmp
PORTVERSION= 5.1
PORTREVISION= 1
CATEGORIES= net ipv6
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= net-snmp

View File

@ -0,0 +1,24 @@
--- agent/mibgroup/ucd-snmp/file.c.orig Thu Dec 25 23:57:14 2003
+++ agent/mibgroup/ucd-snmp/file.c Thu Dec 25 23:57:37 2003
@@ -91,17 +91,19 @@
file_parse_config(const char *token, char *cptr)
{
char space;
+ int items;
if (fileCount < MAXFILE) {
fileTable[fileCount].max = -1;
- sscanf(cptr, "%255s%c%d",
+ memset(fileTable[fileCount].name, 0, sizeof(fileTable[0].name));
+ items = sscanf(cptr, "%255s%c%d",
fileTable[fileCount].name, &space, &fileTable[fileCount].max);
/*
* Log an error then return if the string scanned in was larger then
* it should have been.
*/
- if (space != ' ') {
+ if (items != 1 && space != ' ') {
snmp_log(LOG_ERR, "file_parse_config: file name scanned " \
"in from line %s is too large. fileCount = %d\n", cptr,
fileCount);

View File

@ -7,6 +7,7 @@
PORTNAME= net-snmp
PORTVERSION= 5.1
PORTREVISION= 1
CATEGORIES= net ipv6
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= net-snmp

View File

@ -0,0 +1,24 @@
--- agent/mibgroup/ucd-snmp/file.c.orig Thu Dec 25 23:57:14 2003
+++ agent/mibgroup/ucd-snmp/file.c Thu Dec 25 23:57:37 2003
@@ -91,17 +91,19 @@
file_parse_config(const char *token, char *cptr)
{
char space;
+ int items;
if (fileCount < MAXFILE) {
fileTable[fileCount].max = -1;
- sscanf(cptr, "%255s%c%d",
+ memset(fileTable[fileCount].name, 0, sizeof(fileTable[0].name));
+ items = sscanf(cptr, "%255s%c%d",
fileTable[fileCount].name, &space, &fileTable[fileCount].max);
/*
* Log an error then return if the string scanned in was larger then
* it should have been.
*/
- if (space != ' ') {
+ if (items != 1 && space != ' ') {
snmp_log(LOG_ERR, "file_parse_config: file name scanned " \
"in from line %s is too large. fileCount = %d\n", cptr,
fileCount);