Hi!
The patch I refer to in previous mails has been just applied upstream
to php 5.2, 5.3 and 6.0 as you can see here:
http://marc.info/?t=122064976800003&r=1&w=2
I am attaching it here since I didn't find a way to upload to php's
bugzilla (I've just paste it in the comments, which generates lot of
whitespaces).
Please consider applying the patch as its has been applied upstream
and the php-snmp extension without this patch is really unusable for
us (i.e. we could not run a simple "snmpget", as the 'reproduce code'
int the upstream's bug report shows, without a leak.)
Thanks a lot,
Rodrigo
--- ext/snmp/snmp.c.orig 2008-07-15 10:49:14.000000000 -0300
+++ ext/snmp/snmp.c 2008-07-15 15:01:48.000000000 -0300
@@ -417,13 +417,13 @@
while (keepwalking) {
keepwalking = 0;
if ((st == SNMP_CMD_GET) || (st == SNMP_CMD_GETNEXT)) {
- pdu = snmp_pdu_create((st == SNMP_CMD_GET) ? SNMP_MSG_GET : SNMP_MSG_GETNEXT);
name_length = MAX_OID_LEN;
if (!snmp_parse_oid(objid, name, &name_length)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid object identifier: %s", objid);
snmp_close(ss);
RETURN_FALSE;
}
+ pdu = snmp_pdu_create((st == SNMP_CMD_GET) ? SNMP_MSG_GET : SNMP_MSG_GETNEXT);
snmp_add_null_var(pdu, name, name_length);
} else if (st == SNMP_CMD_SET) {
pdu = snmp_pdu_create(SNMP_MSG_SET);
@@ -434,6 +434,7 @@
sprint_objid(buf, name, name_length);
#endif
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not add variable: %s %c %s", buf, type, value);
+ snmp_free_pdu(pdu);
snmp_close(ss);
RETURN_FALSE;
}
@@ -467,11 +468,13 @@
*return_value = *snmpval;
zval_copy_ctor(return_value);
zval_ptr_dtor(&snmpval);
+ snmp_free_pdu(response);
snmp_close(ss);
return;
} else if (st == SNMP_CMD_GETNEXT) {
*return_value = *snmpval;
zval_copy_ctor(return_value);
+ snmp_free_pdu(response);
snmp_close(ss);
return;
} else if (st == SNMP_CMD_WALK) {
@@ -510,23 +513,28 @@
}
if (st == SNMP_CMD_GET) {
if ((pdu = snmp_fix_pdu(response, SNMP_MSG_GET)) != NULL) {
+ snmp_free_pdu(response);
goto retry;
}
} else if (st == SNMP_CMD_SET) {
if ((pdu = snmp_fix_pdu(response, SNMP_MSG_SET)) != NULL) {
+ snmp_free_pdu(response);
goto retry;
}
} else if (st == SNMP_CMD_GETNEXT) {
if ((pdu = snmp_fix_pdu(response, SNMP_MSG_GETNEXT)) != NULL) {
+ snmp_free_pdu(response);
goto retry;
}
} else if (st >= SNMP_CMD_WALK) { /* Here we do walks. */
if ((pdu = snmp_fix_pdu(response, ((session->version == SNMP_VERSION_1)
? SNMP_MSG_GETNEXT
: SNMP_MSG_GETBULK))) != NULL) {
+ snmp_free_pdu(response);
goto retry;
}
}
+ snmp_free_pdu(response);
snmp_close(ss);
if (st == SNMP_CMD_WALK || st == SNMP_CMD_REALWALK) {
zval_dtor(return_value);