Skip to content

Commit ae75d43

Browse files
committed
MFH: Fix #32009 crash when mssql_bind() is called more than once
1 parent da2d7e7 commit ae75d43

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

NEWS

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ PHP NEWS
44
- Fixed bug #35278 (Multiple virtual() calls crash Apache 2 php module). (Ilia)
55
- Fixed bug #35273 (Error in mapping soap - java types). (Dmitry)
66
- Fixed bug #33153 (crash in mssql_next result). (Frank)
7+
- Fixed bug #32009 (crash when mssql_bind() is called more than once). (Frank)
78

89
17 Nov 2005, PHP 5.1 Release Candidate 6
910
- Changed function parameter parsing to handle integers in a non-strict fashion

ext/mssql/php_mssql.c

+16-11
Original file line numberDiff line numberDiff line change
@@ -2116,17 +2116,22 @@ PHP_FUNCTION(mssql_bind)
21162116
zend_hash_init(statement->binds, 13, NULL, _mssql_bind_hash_dtor, 0);
21172117
}
21182118

2119-
memset((void*)&bind,0,sizeof(mssql_bind));
2120-
zend_hash_add(statement->binds,Z_STRVAL_PP(param_name),Z_STRLEN_PP(param_name),&bind,sizeof(mssql_bind),(void **)&bindp);
2121-
if( NULL == bindp ) RETURN_FALSE;
2122-
bindp->zval=*var;
2123-
zval_add_ref(var);
2124-
2125-
/* no call to dbrpcparam if RETVAL */
2126-
if ( strcmp("RETVAL",Z_STRVAL_PP(param_name))!=0 ) {
2127-
if (dbrpcparam(mssql_ptr->link, Z_STRVAL_PP(param_name), (BYTE)status, type, maxlen, datalen, (LPBYTE)value)==FAIL) {
2128-
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to set parameter");
2129-
RETURN_FALSE;
2119+
if (zend_hash_exists(statement->binds, Z_STRVAL_PP(param_name), Z_STRLEN_PP(param_name))) {
2120+
RETURN_FALSE;
2121+
}
2122+
else {
2123+
memset((void*)&bind,0,sizeof(mssql_bind));
2124+
zend_hash_add(statement->binds, Z_STRVAL_PP(param_name), Z_STRLEN_PP(param_name), &bind, sizeof(mssql_bind), (void **)&bindp);
2125+
if( NULL == bindp ) RETURN_FALSE;
2126+
bindp->zval=*var;
2127+
zval_add_ref(var);
2128+
2129+
/* no call to dbrpcparam if RETVAL */
2130+
if ( strcmp("RETVAL",Z_STRVAL_PP(param_name))!=0 ) {
2131+
if (dbrpcparam(mssql_ptr->link, Z_STRVAL_PP(param_name), (BYTE)status, type, maxlen, datalen, (LPBYTE)value)==FAIL) {
2132+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to set parameter");
2133+
RETURN_FALSE;
2134+
}
21302135
}
21312136
}
21322137

0 commit comments

Comments
 (0)