fix the problem of using strtoul in priority_boost_parse and flush_parse
PATCH 1/1 fix the problem of using strtoul in priority_boost_parse and flush_parse
Hello,
When the configure value of priority_boost or flush is larger than INT_MAX,
auditd is still started successfully. The priority_boost_parser and flush_parse code use an int variable to store the result strtoul() and then compared with INT_MAX.
The attached patch fixes the problem in src/auditd-config.c andaudisp/audispd-config.c.
Regards
Chu Li
audisp/audispd-config.c +4 -3
@@ -388,6 +388,7 @@ {const char *ptr = nv->value;int i; +unsigned long j;audit_msg (LOG_DEBUG ,"priority_boost_parser called with: %s" , nv->value);
@@ -403,7 +404,7 @@ }/* convert to unsigned int */ errno =0 ; - i =strtoul (nv->value,NULL ,10 ); + j =strtoul (nv->value,NULL ,10 );if (errno) { audit_msg(LOG_ERR, "Error converting string to a number (%s) - line %d",
@@ -411,13 +412,13 @@return 1 ; }/* Check its range */ -if (i >INT_MAX ) { +if (j >INT_MAX ) {audit_msg (LOG_ERR ,"Error - converted number (%s) is too large - line %d" , nv->value, line);return 1 ; } - config->priority_boost = (unsigned int )i; + config->priority_boost = (unsigned int )j;return 0 ; }
src/auditd-config.c +8 -6
@@ -783,6 +783,7 @@ {const char *ptr = nv->value;int i; +unsigned long j;audit_msg (LOG_DEBUG ,"freq_parser called with: %s" , nv->value);
@@ -798,7 +799,7 @@/* convert to unsigned int */ errno =0 ; - i =strtoul (nv->value,NULL ,10 ); + j =strtoul (nv->value,NULL ,10 );if (errno) { audit_msg(LOG_ERR, "Error converting string to a number (%s) - line %d",
@@ -806,13 +807,13 @@return 1 ; }/* Check its range */ -if (i >INT_MAX ) { +if (j >INT_MAX ) {audit_msg (LOG_ERR ,"Error - converted number (%s) is too large - line %d" , nv->value, line);return 1 ; } - config->freq = (unsigned int )i; + config->freq = (unsigned int )j;return 0 ; }
@@ -1113,6 +1114,7 @@ {const char *ptr = nv->value;int i; +unsigned long j;audit_msg (LOG_DEBUG ,"priority_boost_parser called with: %s" , nv->value);
@@ -1129,7 +1131,7 @@/* convert to unsigned int */ errno =0 ; - i =strtoul (nv->value,NULL ,10 ); + j =strtoul (nv->value,NULL ,10 );if (errno) { audit_msg(LOG_ERR, "Error converting string to a number (%s) - line %d",
@@ -1137,13 +1139,13 @@return 1 ; }/* Check its range */ -if (i >INT_MAX ) { +if (j >INT_MAX ) {audit_msg (LOG_ERR ,"Error - converted number (%s) is too large - line %d" , nv->value, line);return 1 ; } - config->priority_boost = (unsigned int )i; + config->priority_boost = (unsigned int )j;return 0 ; }