@@ -305,6 +305,7 @@ PHP_MINIT_FUNCTION(mssql)
305
305
REGISTER_LONG_CONSTANT ("SQLINT4" ,SQLINT4 , CONST_CS | CONST_PERSISTENT );
306
306
REGISTER_LONG_CONSTANT ("SQLBIT" ,SQLBIT , CONST_CS | CONST_PERSISTENT );
307
307
REGISTER_LONG_CONSTANT ("SQLFLT8" ,SQLFLT8 , CONST_CS | CONST_PERSISTENT );
308
+ REGISTER_LONG_CONSTANT ("SQLFLTN" ,SQLFLTN , CONST_CS | CONST_PERSISTENT );
308
309
/* END MSSQL data types for mssql_sp_bind */
309
310
310
311
return SUCCESS ;
@@ -373,7 +374,7 @@ static void php_mssql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
373
374
case 0 : /* defaults */
374
375
host = user = passwd = NULL ;
375
376
hashed_details_length = 5 + 3 ;
376
- hashed_details = (char * ) emalloc (hashed_details_length + 1 );
377
+ hashed_details = (char * ) emalloc (hashed_details_length );
377
378
strcpy (hashed_details ,"mssql___" );
378
379
break ;
379
380
case 1 : {
@@ -386,7 +387,7 @@ static void php_mssql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
386
387
host = Z_STRVAL_PP (yyhost );
387
388
user = passwd = NULL ;
388
389
hashed_details_length = Z_STRLEN_PP (yyhost )+ 5 + 3 ;
389
- hashed_details = (char * ) emalloc (hashed_details_length + 1 );
390
+ hashed_details = (char * ) emalloc (hashed_details_length );
390
391
sprintf (hashed_details ,"mssql_%s__" ,Z_STRVAL_PP (yyhost ));
391
392
}
392
393
break ;
@@ -402,7 +403,7 @@ static void php_mssql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
402
403
user = Z_STRVAL_PP (yyuser );
403
404
passwd = NULL ;
404
405
hashed_details_length = Z_STRLEN_PP (yyhost )+ Z_STRLEN_PP (yyuser )+ 5 + 3 ;
405
- hashed_details = (char * ) emalloc (hashed_details_length + 1 );
406
+ hashed_details = (char * ) emalloc (hashed_details_length );
406
407
sprintf (hashed_details ,"mssql_%s_%s_" ,Z_STRVAL_PP (yyhost ),Z_STRVAL_PP (yyuser ));
407
408
}
408
409
break ;
@@ -419,7 +420,7 @@ static void php_mssql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
419
420
user = Z_STRVAL_PP (yyuser );
420
421
passwd = Z_STRVAL_PP (yypasswd );
421
422
hashed_details_length = Z_STRLEN_PP (yyhost )+ Z_STRLEN_PP (yyuser )+ Z_STRLEN_PP (yypasswd )+ 5 + 3 ;
422
- hashed_details = (char * ) emalloc (hashed_details_length + 1 );
423
+ hashed_details = (char * ) emalloc (hashed_details_length );
423
424
sprintf (hashed_details ,"mssql_%s_%s_%s" ,Z_STRVAL_PP (yyhost ),Z_STRVAL_PP (yyuser ),Z_STRVAL_PP (yypasswd )); /* SAFE */
424
425
}
425
426
break ;
@@ -442,7 +443,7 @@ static void php_mssql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
442
443
dbprocerrhandle (mssql .login , (DBERRHANDLE_PROC ) php_mssql_error_handler );
443
444
dbprocmsghandle (mssql .login , (DBMSGHANDLE_PROC ) php_mssql_message_handler );
444
445
445
- if (MS_SQL_G (secure_connection )){
446
+ if (MS_SQL_G (secure_connection ) == 1 ){
446
447
DBSETLSECURE (mssql .login );
447
448
}
448
449
else {
@@ -778,19 +779,22 @@ static void php_mssql_get_column_content_with_type(mssql_link *mssql_ptr,int off
778
779
Z_TYPE_P (result ) = IS_STRING ;
779
780
break ;
780
781
}
781
- case SQLFLT8 : {
782
- Z_DVAL_P (result ) = (double ) floatcol (offset );
782
+ case SQLFLT4 :
783
+ Z_DVAL_P (result ) = (double ) floatcol4 (offset );
784
+ Z_TYPE_P (result ) = IS_DOUBLE ;
785
+ break ;
786
+ case SQLFLT8 :
787
+ Z_DVAL_P (result ) = (double ) floatcol8 (offset );
783
788
Z_TYPE_P (result ) = IS_DOUBLE ;
784
789
break ;
785
- }
786
790
case SQLVARBINARY :
787
791
case SQLBINARY :
788
792
case SQLIMAGE : {
789
793
DBBINARY * bin ;
790
794
unsigned char * res_buf ;
791
795
int res_length = dbdatlen (mssql_ptr -> link , offset );
792
796
793
- res_buf = (unsigned char * ) emalloc (res_length + 1 );
797
+ res_buf = (unsigned char * ) emalloc (res_length );
794
798
bin = ((DBBINARY * )dbdata (mssql_ptr -> link , offset ));
795
799
memcpy (res_buf ,bin ,res_length );
796
800
res_buf [res_length ] = '\0' ;
@@ -811,13 +815,13 @@ static void php_mssql_get_column_content_with_type(mssql_link *mssql_ptr,int off
811
815
if (column_type == SQLDATETIM4 ) res_length += 14 ;
812
816
if (column_type == SQLDATETIME ) res_length += 10 ;
813
817
814
- res_buf = (unsigned char * ) emalloc (res_length + 1 );
818
+ res_buf = (unsigned char * ) emalloc (res_length );
815
819
res_length = dbconvert (NULL ,coltype (offset ),dbdata (mssql_ptr -> link ,offset ), res_length , SQLCHAR ,res_buf ,-1 );
816
820
} else {
817
821
dbdatecrack (mssql_ptr -> link , & dateinfo , (DBDATETIME * ) dbdata (mssql_ptr -> link ,offset ));
818
822
819
823
res_length = 19 ;
820
- res_buf = (unsigned char * ) emalloc (res_length + 1 );
824
+ res_buf = (unsigned char * ) emalloc (res_length );
821
825
sprintf (res_buf , "%d-%02d-%02d %02d:%02d:%02d" , dateinfo .year , dateinfo .month , dateinfo .day , dateinfo .hour , dateinfo .minute , dateinfo .second );
822
826
}
823
827
@@ -846,7 +850,7 @@ static void php_mssql_get_column_content_without_type(mssql_link *mssql_ptr,int
846
850
unsigned char * res_buf ;
847
851
int res_length = dbdatlen (mssql_ptr -> link , offset );
848
852
849
- res_buf = (unsigned char * ) emalloc (res_length + 1 );
853
+ res_buf = (unsigned char * ) emalloc (res_length );
850
854
bin = ((DBBINARY * )dbdata (mssql_ptr -> link , offset ));
851
855
memcpy (res_buf , bin , res_length );
852
856
res_buf [res_length ] = '\0' ;
@@ -864,14 +868,14 @@ static void php_mssql_get_column_content_without_type(mssql_link *mssql_ptr,int
864
868
if (column_type == SQLDATETIM4 ) res_length += 14 ;
865
869
if (column_type == SQLDATETIME ) res_length += 10 ;
866
870
867
- res_buf = (unsigned char * ) emalloc (res_length + 1 );
868
- res_length = dbconvert (NULL ,coltype (offset ),dbdata (mssql_ptr -> link ,offset ), res_length , SQLCHAR ,res_buf ,-1 );
871
+ res_buf = (unsigned char * ) emalloc (res_length );
872
+ res_length = dbconvert (NULL ,coltype (offset ),dbdata (mssql_ptr -> link ,offset ), res_length , SQLCHAR , res_buf , -1 );
869
873
870
874
} else {
871
875
dbdatecrack (mssql_ptr -> link , & dateinfo , (DBDATETIME * ) dbdata (mssql_ptr -> link ,offset ));
872
876
873
877
res_length = 19 ;
874
- res_buf = (unsigned char * ) emalloc (res_length + 1 );
878
+ res_buf = (unsigned char * ) emalloc (res_length );
875
879
sprintf (res_buf , "%d-%02d-%02d %02d:%02d:%02d" , dateinfo .year , dateinfo .month , dateinfo .day , dateinfo .hour , dateinfo .minute , dateinfo .second );
876
880
}
877
881
@@ -1881,6 +1885,7 @@ PHP_FUNCTION(mssql_bind)
1881
1885
switch (type ) {
1882
1886
1883
1887
case SQLFLT8 :
1888
+ case SQLFLTN :
1884
1889
convert_to_double_ex (var );
1885
1890
value = (LPBYTE )(& Z_DVAL_PP (var ));
1886
1891
break ;
@@ -2024,6 +2029,7 @@ PHP_FUNCTION(mssql_execute)
2024
2029
break ;
2025
2030
2026
2031
case SQLFLT8 :
2032
+ case SQLFLTN :
2027
2033
convert_to_double_ex (& bind -> zval );
2028
2034
Z_DVAL_P (bind -> zval )= * ((double * )(dbretdata (mssql_ptr -> link ,i )));
2029
2035
break ;
0 commit comments