@@ -44,21 +44,27 @@ array_boundary(enum ARRAY_TYPE isarray, char c)
4444
4545/* returns true if some garbage is found at the end of the scanned string */
4646static bool
47- garbage_left (enum ARRAY_TYPE isarray , char * scan_length , enum COMPAT_MODE compat )
47+ garbage_left (enum ARRAY_TYPE isarray , char * * scan_length , enum COMPAT_MODE compat )
4848{
4949 /*
5050 * INFORMIX allows for selecting a numeric into an int, the result is
5151 * truncated
5252 */
5353 if (isarray == ECPG_ARRAY_NONE )
5454 {
55- if (INFORMIX_MODE (compat ) && * scan_length == '.' )
55+ if (INFORMIX_MODE (compat ) && * * scan_length == '.' )
56+ {
57+ /* skip invalid characters */
58+ do {
59+ (* scan_length )++ ;
60+ } while (* * scan_length != ' ' && * * scan_length != '\0' && isdigit (* * scan_length ));
5661 return false;
62+ }
5763
58- if (* scan_length != ' ' && * scan_length != '\0' )
64+ if (* * scan_length != ' ' && * * scan_length != '\0' )
5965 return true;
6066 }
61- else if (ECPG_IS_ARRAY (isarray ) && !array_delimiter (isarray , * scan_length ) && !array_boundary (isarray , * scan_length ))
67+ else if (ECPG_IS_ARRAY (isarray ) && !array_delimiter (isarray , * * scan_length ) && !array_boundary (isarray , * * scan_length ))
6268 return true;
6369
6470 return false;
@@ -303,7 +309,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
303309 case ECPGt_int :
304310 case ECPGt_long :
305311 res = strtol (pval , & scan_length , 10 );
306- if (garbage_left (isarray , scan_length , compat ))
312+ if (garbage_left (isarray , & scan_length , compat ))
307313 {
308314 ecpg_raise (lineno , ECPG_INT_FORMAT ,
309315 ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
@@ -332,7 +338,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
332338 case ECPGt_unsigned_int :
333339 case ECPGt_unsigned_long :
334340 ures = strtoul (pval , & scan_length , 10 );
335- if (garbage_left (isarray , scan_length , compat ))
341+ if (garbage_left (isarray , & scan_length , compat ))
336342 {
337343 ecpg_raise (lineno , ECPG_UINT_FORMAT ,
338344 ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
@@ -361,7 +367,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
361367#ifdef HAVE_STRTOLL
362368 case ECPGt_long_long :
363369 * ((long long int * ) (var + offset * act_tuple )) = strtoll (pval , & scan_length , 10 );
364- if (garbage_left (isarray , scan_length , compat ))
370+ if (garbage_left (isarray , & scan_length , compat ))
365371 {
366372 ecpg_raise (lineno , ECPG_INT_FORMAT , ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
367373 return (false);
@@ -373,7 +379,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
373379#ifdef HAVE_STRTOULL
374380 case ECPGt_unsigned_long_long :
375381 * ((unsigned long long int * ) (var + offset * act_tuple )) = strtoull (pval , & scan_length , 10 );
376- if (garbage_left (isarray , scan_length , compat ))
382+ if (garbage_left (isarray , & scan_length , compat ))
377383 {
378384 ecpg_raise (lineno , ECPG_UINT_FORMAT , ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
379385 return (false);
@@ -395,7 +401,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
395401 if (isarray && * scan_length == '"' )
396402 scan_length ++ ;
397403
398- if (garbage_left (isarray , scan_length , compat ))
404+ if (garbage_left (isarray , & scan_length , compat ))
399405 {
400406 ecpg_raise (lineno , ECPG_FLOAT_FORMAT ,
401407 ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
@@ -593,7 +599,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
593599 }
594600 else
595601 {
596- if (!isarray && garbage_left (isarray , scan_length , compat ))
602+ if (!isarray && garbage_left (isarray , & scan_length , compat ))
597603 {
598604 free (nres );
599605 ecpg_raise (lineno , ECPG_NUMERIC_FORMAT ,
@@ -651,7 +657,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
651657 if (* scan_length == '"' )
652658 scan_length ++ ;
653659
654- if (!isarray && garbage_left (isarray , scan_length , compat ))
660+ if (!isarray && garbage_left (isarray , & scan_length , compat ))
655661 {
656662 free (ires );
657663 ecpg_raise (lineno , ECPG_INTERVAL_FORMAT ,
@@ -701,7 +707,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
701707 if (* scan_length == '"' )
702708 scan_length ++ ;
703709
704- if (!isarray && garbage_left (isarray , scan_length , compat ))
710+ if (!isarray && garbage_left (isarray , & scan_length , compat ))
705711 {
706712 ecpg_raise (lineno , ECPG_DATE_FORMAT ,
707713 ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
@@ -749,7 +755,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
749755 if (* scan_length == '"' )
750756 scan_length ++ ;
751757
752- if (!isarray && garbage_left (isarray , scan_length , compat ))
758+ if (!isarray && garbage_left (isarray , & scan_length , compat ))
753759 {
754760 ecpg_raise (lineno , ECPG_TIMESTAMP_FORMAT ,
755761 ECPG_SQLSTATE_DATATYPE_MISMATCH , pval );
0 commit comments