Skip to content

PHP-7.0-Linux sqlsrv_query produces floating point exception when bind parameter is a empty string #144

@xalopp

Description

@xalopp

While this query worked fine with version 4.0.2 of sqlsrv

sqlsrv_query($conn, 'SELECT ?', ['']);

version 4.0.3 will produce a floating point exception for the same query.

Core was generated by `/usr/bin/php7.0 -n -c /vagrant/msphpsql/source/sqlsrv/tmp-php.ini -d output_han'.
Program terminated with signal SIGFPE, Arithmetic exception.
#0  0x00007f4d923dd0c6 in (anonymous namespace)::default_sql_size_and_scale (param_z=0x7f4d9265cf68, param_z=0x7f4d9265cf68, 
    decimal_digits=<synthetic pointer>, column_size=<synthetic pointer>, encoding=SQLSRV_ENCODING_CHAR, paramno=3, stmt=0x7f4d9266e000)
    at /vagrant/msphpsql/source/sqlsrv/core_stmt.cpp:1963
1963                    column_size = SQL_SERVER_MAX_FIELD_SIZE / char_size;

char_size is defined in line 1957, an will be 0 if Z_STRLEN_P( param_z ) is zero, which happens for an empty string.

My Environment:
Ubuntu 16.04 LTSUbuntu 16.04 LTS
PHP 7.0.10-1+deb.sury.org~xenial+1 (cli) ( NTS )PHP 7.0.10-1+deb.sury.org~xenial+1 (cli) ( NTS )

This issue is similar to #141 where pdo_sqlsrv is affected.

PR is in Progress.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions