snmp: change uses of sprintf into snprintf

This commit is contained in:
Niels Dossche 2024-06-09 19:39:43 +02:00
parent b1fd3477b2
commit 429f91d80d

View file

@ -528,7 +528,7 @@ retry:
buf2[0] = '\0'; buf2[0] = '\0';
count = rootlen; count = rootlen;
while(count < vars->name_length){ while(count < vars->name_length){
sprintf(buf, "%lu.", vars->name[count]); snprintf(buf, sizeof(buf), "%lu.", vars->name[count]);
strcat(buf2, buf); strcat(buf2, buf);
count++; count++;
} }
@ -873,8 +873,9 @@ static bool netsnmp_session_init(php_snmp_session **session_p, int version, zend
/* put back non-standard SNMP port */ /* put back non-standard SNMP port */
if (remote_port != SNMP_PORT) { if (remote_port != SNMP_PORT) {
pptr = session->peername + strlen(session->peername); size_t peername_length = strlen(session->peername);
sprintf(pptr, ":%d", remote_port); pptr = session->peername + peername_length;
snprintf(pptr, MAX_NAME_LEN - peername_length, ":%d", remote_port);
} }
php_network_freeaddresses(psal); php_network_freeaddresses(psal);