Skip to content

Commit 429f91d

Browse files
committed
snmp: change uses of sprintf into snprintf
1 parent b1fd347 commit 429f91d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ext/snmp/snmp.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ static void php_snmp_internal(INTERNAL_FUNCTION_PARAMETERS, int st,
528528
buf2[0] = '\0';
529529
count = rootlen;
530530
while(count < vars->name_length){
531-
sprintf(buf, "%lu.", vars->name[count]);
531+
snprintf(buf, sizeof(buf), "%lu.", vars->name[count]);
532532
strcat(buf2, buf);
533533
count++;
534534
}
@@ -873,8 +873,9 @@ static bool netsnmp_session_init(php_snmp_session **session_p, int version, zend
873873

874874
/* put back non-standard SNMP port */
875875
if (remote_port != SNMP_PORT) {
876-
pptr = session->peername + strlen(session->peername);
877-
sprintf(pptr, ":%d", remote_port);
876+
size_t peername_length = strlen(session->peername);
877+
pptr = session->peername + peername_length;
878+
snprintf(pptr, MAX_NAME_LEN - peername_length, ":%d", remote_port);
878879
}
879880

880881
php_network_freeaddresses(psal);

0 commit comments

Comments
 (0)