mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
osasnmpd: Fix SNMP non-compliance
Update osasnmpd to support Object ID Sub-IDs with length up-to and including 10 digits, in line with SNMP specification. While at it, also replace sprintf() calls with snprintf(). Together, these changes contribute to better memory safety. Suggested-by: Alexandra Winter <wintera@linux.ibm.com> Reviewed-by: Hidayath Khan <hidayath@linux.ibm.com> Signed-off-by: Aswin Karuvally <aswin@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
6f9f846bc0
commit
a05935cca9
@@ -44,7 +44,20 @@
|
||||
#define MAX_GET_DATA 4094 /* maximum GET response data length */
|
||||
#define GET_AREA_LEN MAX_GET_DATA + 512 /* size for GET command area length */
|
||||
#define TIME_BUF_SIZE 128 /* buffer size for date and time string */
|
||||
#define MAX_OID_STR_LEN MAX_OID_LEN * 5 /* max OID string size */
|
||||
|
||||
/*
|
||||
* Define maximum SNMP OID string size.
|
||||
* An OID can have up to 128 sub-ids and each sub-id can have up to 10
|
||||
* digits. When converted to string, this means 1 character for the
|
||||
* period separator and 10 characters for the digits themselves. At
|
||||
* the end of OID string, we need one more character for the null
|
||||
* terminator. The unsigned long data type, which can have up to 20
|
||||
* digits is used to represent a sub-id. This means each sub-id
|
||||
* string now needs 20+1 characters instead of 10+1 in-order to avoid
|
||||
* compiler warnings.
|
||||
*/
|
||||
#define MAX_OID_STR_LEN (MAX_OID_LEN * 21) + 1
|
||||
|
||||
/* definitions for 2.6 qeth */
|
||||
#define QETH_SYSFILE "/sys/bus/ccwgroup/drivers/qeth/notifier_register"
|
||||
#define SIOC_QETH_ADP_SET_SNMP_CONTROL (SIOCDEVPRIVATE + 5)
|
||||
|
||||
@@ -110,7 +110,7 @@ int str_to_oid_conv ( char* uc_oid, oid* ul_oid )
|
||||
*********************************************************************/
|
||||
int oid_to_str_conv (oid* ul_oid, size_t length, char* uc_oid )
|
||||
{
|
||||
#define MAX_CHARS 50 /* size of buffer */
|
||||
#define MAX_CHARS 22 /* size of buffer */
|
||||
int i;
|
||||
short valid = TRUE;
|
||||
char buffer[MAX_CHARS]; /* buffer used for conversion */
|
||||
@@ -125,9 +125,9 @@ int oid_to_str_conv (oid* ul_oid, size_t length, char* uc_oid )
|
||||
{
|
||||
/* convert and append OID digit to return string */
|
||||
if (i == 0)
|
||||
sprintf( buffer, "%lu", ul_oid[i] );
|
||||
snprintf( buffer, sizeof(buffer), "%lu", ul_oid[i] );
|
||||
else
|
||||
sprintf( buffer, ".%lu", ul_oid[i] );
|
||||
snprintf( buffer, sizeof(buffer), ".%lu", ul_oid[i] );
|
||||
|
||||
strcat( uc_oid, buffer );
|
||||
} /* end for */
|
||||
|
||||
Reference in New Issue
Block a user