Commit 3f9d0bc8ea3 for php.net

commit 3f9d0bc8ea37c805f2e05837667ddb2e84485667
Merge: df4a960ff89 0c2fc141fcf
Author: Ilia Alshanetsky <ilia@ilia.ws>
Date:   Mon Sep 7 18:41:05 2026 -0400

    Merge branch 'PHP-8.4' into PHP-8.5

    * PHP-8.4:
      odbc: check SQLColAttribute return codes in the field info functions

diff --cc NEWS
index 236c96b42b4,935583e8733..56204f6ecc6
--- a/NEWS
+++ b/NEWS
@@@ -60,8 -66,17 +60,13 @@@ PH
      replacement when a \k<name> backref has no closing delimiter.
      (Ilia Alshanetsky)

+ - ODBC:
+   . Fixed odbc_field_len(), odbc_field_scale() and odbc_field_type()
+     returning uninitialized memory when SQLColAttribute fails.
+     (Ilia Alshanetsky)
+
  - Opcache:
 -  . Fixed a crash when the huge page SHM remap discarded mappings outside the
 -    reserved address range. (Piotr Hałas)
    . Fixed opcache.protect_memory race under ZTS. (realFlowControl)
 -  . Fixed bug GH-23288 (Crash on restart when opcache.interned_strings_buffer
 -    is overridden in an individual FPM pool). (David Carlier)
    . Fixed a tracing JIT crash when compiling a side trace for a method of a
      class that could not be stored in the inheritance cache. (GH-21710)
      (Arnaud, iliaal)
diff --cc ext/odbc/php_odbc.c
index b8771cf8809,798245c4ca9..3ed365cab96
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@@ -673,10 -683,11 +673,11 @@@ void odbc_bindcols(odbc_result *result
  		result->values[i].value_max_len = 0;
  		colfieldid = SQL_COLUMN_DISPLAY_SIZE;

+ 		result->values[i].name[0] = '\0';
 -		rc = PHP_ODBC_SQLCOLATTRIBUTE(result->stmt, (SQLUSMALLINT)(i+1), PHP_ODBC_SQL_DESC_NAME,
 +		rc = SQLColAttribute(result->stmt, (SQLUSMALLINT)(i+1), SQL_DESC_NAME,
  				result->values[i].name, sizeof(result->values[i].name), &colnamelen, 0);
  		result->values[i].coltype = 0;
 -		rc = PHP_ODBC_SQLCOLATTRIBUTE(result->stmt, (SQLUSMALLINT)(i+1), SQL_COLUMN_TYPE,
 +		rc = SQLColAttribute(result->stmt, (SQLUSMALLINT)(i+1), SQL_COLUMN_TYPE,
  				NULL, 0, NULL, &result->values[i].coltype);

  		/* Don't bind LONG / BINARY columns, so that fetch behaviour can
@@@ -786,7 -833,18 +806,8 @@@ static void odbc_colattribute_failed(od
  void odbc_column_lengths(INTERNAL_FUNCTION_PARAMETERS, int type)
  {
  	odbc_result *result;
+ 	RETCODE rc;
 -#if defined(HAVE_SOLID) || defined(HAVE_SOLID_30)
 -	/* this seems to be necessary for Solid2.3 ( tested by
 -	 * tammy@synchronis.com) and Solid 3.0 (tested by eric@terra.telemediair.nl)
 -	 * Solid does not seem to declare a SQLINTEGER, but it does declare a
 -	 * SQL_INTEGER which does not work (despite being the same type as a SDWORD.
 -	 * Solid 3.5 does not have this issue.
 -	 */
 -	SDWORD len;
 -#else
  	SQLLEN len;
 -#endif
  	zval *pv_res;
  	zend_long pv_num;

@@@ -812,7 -870,11 +833,11 @@@
  		RETURN_FALSE;
  	}

- 	SQLColAttribute(result->stmt, (SQLUSMALLINT)pv_num, (SQLUSMALLINT) (type?SQL_COLUMN_SCALE:SQL_COLUMN_PRECISION), NULL, 0, NULL, &len);
 -	rc = PHP_ODBC_SQLCOLATTRIBUTE(result->stmt, (SQLUSMALLINT)pv_num, (SQLUSMALLINT)(type ? SQL_COLUMN_SCALE : SQL_COLUMN_PRECISION), NULL, 0, NULL, &len);
++	rc = SQLColAttribute(result->stmt, (SQLUSMALLINT)pv_num, (SQLUSMALLINT)(type ? SQL_COLUMN_SCALE : SQL_COLUMN_PRECISION), NULL, 0, NULL, &len);
+ 	if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
+ 		odbc_colattribute_failed(result, pv_num);
+ 		len = 0;
+ 	}

  	RETURN_LONG(len);
  }
@@@ -2475,7 -2648,13 +2501,13 @@@ PHP_FUNCTION(odbc_field_type
  		RETURN_FALSE;
  	}

- 	SQLColAttribute(result->stmt, (SQLUSMALLINT)pv_num, SQL_COLUMN_TYPE_NAME, tmp, 31, &tmplen, NULL);
+ 	tmp[0] = '\0';
 -	rc = PHP_ODBC_SQLCOLATTRIBUTE(result->stmt, (SQLUSMALLINT)pv_num, SQL_COLUMN_TYPE_NAME, tmp, sizeof(tmp) - 1, &tmplen, NULL);
++	rc = SQLColAttribute(result->stmt, (SQLUSMALLINT)pv_num, SQL_COLUMN_TYPE_NAME, tmp, sizeof(tmp) - 1, &tmplen, NULL);
+ 	if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
+ 		odbc_colattribute_failed(result, pv_num);
+ 		RETURN_FALSE;
+ 	}
+
  	RETURN_STRING(tmp);
  }
  /* }}} */