1
0
mirror of https://github.com/php/php-src.git synced 2026-04-29 03:03:26 +02:00

Merge branch 'PHP-5.4' into PHP-5.5

* PHP-5.4:
  re-work walkaround for net-snmp BUGid 2027834, no need to detect it anymore add test for Bug #64159 bump default buffer size for values(32->512): do not reallocate buffers in 99% cases
This commit is contained in:
Boris Lytochkin
2013-05-03 23:10:11 +04:00
6 changed files with 43 additions and 66 deletions
-61
View File
@@ -59,67 +59,6 @@ if test "$PHP_SNMP" != "no"; then
$SNMP_SHARED_LIBADD
])
dnl Check for buggy snmp_snprint_value() (net-snmp BUGid 2027834)
AC_CACHE_CHECK([for buggy snmp_snprint_value], ac_cv_buggy_snprint_value,[
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -I${SNMP_PREFIX}/include $SNMP_SHARED_LIBADD"
AC_TRY_RUN( [
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
u_char uname[] = "Linux nex1.php.net 2.6.18-194.32.1.el5 #1 SMP Wed Jan 5 17:53:09 EST 2011 i686";
int main(int argc, char **argv)
{
struct variable_list vars;
char buf1[2048];
char buf2[sizeof(buf1)];
memset(&(buf1[0]), 0, sizeof(buf1));
memset(&(buf2[0]), 0, sizeof(buf2));
memset(&vars, 0, sizeof(vars));
vars.type = 4;
vars.val.integer = (long *)&(uname[0]);
vars.val.string = &(uname[0]);
vars.val.bitstring = &(uname[0]);
vars.val.counter64 = (struct counter64 *)&(uname[0]);
vars.val.floatVal = (float *)&(uname[0]);
vars.val_len = sizeof(uname),
vars.name_loc[0] = 1;
vars.name_loc[1] = 3;
vars.name_loc[2] = 6;
vars.name_loc[3] = 1;
vars.name_loc[4] = 2;
vars.name_loc[5] = 1;
vars.name_loc[6] = 1;
vars.name_loc[7] = 1;
vars.name = (oid *)&(vars.name_loc);
vars.name_length = 9;
init_snmp("snmpapp");
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT, 0);
snprint_value(buf1, (sizeof(uname) + 32), vars.name, vars.name_length, &vars);
snprint_value(buf2, sizeof(buf2), vars.name, vars.name_length, &vars);
exit((strncmp(buf1, buf2, sizeof(buf1)) != 0));
}
],[
ac_cv_buggy_snprint_value=no
],[
ac_cv_buggy_snprint_value=yes
],[
ac_cv_buggy_snprint_value=no
])
CFLAGS="$save_CFLAGS"
])
if test "$ac_cv_buggy_snprint_value" = "yes"; then
AC_DEFINE(BUGGY_SNMPRINT_VALUE, 1, [ ])
fi
PHP_NEW_EXTENSION(snmp, snmp.c, $ext_shared)
PHP_SUBST(SNMP_SHARED_LIBADD)
fi
+5 -5
View File
@@ -551,11 +551,7 @@ static void php_snmp_error(zval *object, const char *docref TSRMLS_DC, int type,
static void php_snmp_getvalue(struct variable_list *vars, zval *snmpval TSRMLS_DC, int valueretrieval)
{
zval *val;
#ifdef BUGGY_SNMPRINT_VALUE
char sbuf[2048];
#else
char sbuf[64];
#endif
char sbuf[512];
char *buf = &(sbuf[0]);
char *dbuf = (char *)NULL;
int buflen = sizeof(sbuf) - 1;
@@ -569,6 +565,10 @@ static void php_snmp_getvalue(struct variable_list *vars, zval *snmpval TSRMLS_D
while ((valueretrieval & SNMP_VALUE_PLAIN) == 0) {
*buf = '\0';
if (snprint_value(buf, buflen, vars->name, vars->name_length, vars) == -1) {
if (val_len > 512*1024) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "snprint_value() asks for a buffer more than 512k, Net-SNMP bug?");
break;
}
/* buffer is not long enough to hold full output, double it */
val_len *= 2;
} else {
+2
View File
@@ -35,6 +35,8 @@ On Linux/FreeBSD
Before launching daemon make sure that there is no file /var/net-snmp/snmpd.conf
Delete it if exists. Ingoring to to so will fail SNMPv3 tests.
- Place bigtest.sh near snmpd.conf, tune path to it in snmpd.conf
- Launch snmpd (service snmpd start or /etc/init.d/snmpd start).
Alternatively you can start snmpd daemon using following command line:
sudo snmpd -C -c ./snmpd.conf -f -Le
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
Q="";
i=0;
while [ $i -lt 32 ]; do
Q="${Q}\3\2\4\11\22\13\14\15\16\17\20\21\22\23\24\25\26\27";
i=$((i+1));
done
printf "${Q}"
+24
View File
@@ -0,0 +1,24 @@
--TEST--
Bug #64159: Truncated snmpget
--CREDITS--
Boris Lytochkin
--SKIPIF--
<?php
require_once(dirname(__FILE__).'/skipif.inc');
?>
--ENV--
MIBS=noneXistent
--FILE--
<?php
require_once(dirname(__FILE__).'/snmp_include.inc');
snmp_set_quick_print(false);
snmp_set_valueretrieval(SNMP_VALUE_LIBRARY);
var_dump(("ab8283f948419b2d24d22f44a80b17d3" === md5(snmpget($hostname, $community, '.1.3.6.1.4.1.2021.8.1.101.2'))));
?>
--EXPECTF--
MIB search path: %s
Cannot find module (noneXistent): At line %d in (%s)
bool(true)
+2
View File
@@ -23,3 +23,5 @@ createUser adminMD5DES MD5 test1234 DES test1234
createUser noAuthUser
authuser read noAuthUser noauth
exec HexTest /bin/sh /etc/snmp/bigtest.sh