Package: release.debian.org Severity: normal Tags: stretch User: release.debian....@packages.debian.org Usertags: pu
libdbd-firebird-perl before 1.25 suffers from a bug (#877720) leading to data corruption when fetching decimal(x,y) values between -1 and 0. The fetched data is positive, instead of negative. (libdbd-firebird-perl is a driver for connecting DBI, the standard Perl database interface, to Firebird SQL server) The fix is taken from the upstream commit (of which I am also the author). Targeted patch and full source debdiff attached. -- dam
b4fad5d264abafeb26e1333b74f6a5c2f75f4869 dbd_st_fetch: fix conversion of numerics between -1 and 0 diff --git a/dbdimp.c b/dbdimp.c index 1c48d7c..ff7b510 100644 --- a/dbdimp.c +++ b/dbdimp.c @@ -1431,20 +1431,28 @@ AV *dbd_st_fetch(SV *sth, imp_sth_t *imp_sth) #endif if (var->sqlscale == 0) { snprintf(buf, sizeof(buf), "%"DBD_IB_INT64f, i); + sv_setpvn(sv, buf, strlen(buf)); } else { + bool sign = ( i < 0 ); ISC_INT64 divisor, remainder; divisor = scales[-var->sqlscale]; + if (sign) divisor = -divisor; remainder = (i%divisor); if (remainder < 0) remainder = -remainder; - snprintf(buf, sizeof(buf), + snprintf(buf+1, sizeof(buf)-1, "%"DBD_IB_INT64f".%0*"DBD_IB_INT64f, i/divisor, -var->sqlscale, remainder); DBI_TRACE_imp_xxh(imp_sth, 3, (DBIc_LOGPIO(imp_sth), "-------------->SQLINT64=%"DBD_IB_INT64f".%0*"DBD_IB_INT64f,i/divisor, -var->sqlscale, remainder )); + if (sign) { + *buf = '-'; + sv_setpvn(sv, buf, strlen(buf)); + } + else { + sv_setpvn(sv, buf+1, strlen(buf+1)); + } } - - sv_setpvn(sv, buf, strlen(buf)); } break; #endif
diff -Nru libdbd-firebird-perl-1.24/debian/changelog libdbd-firebird-perl-1.24/debian/changelog --- libdbd-firebird-perl-1.24/debian/changelog 2016-10-11 12:02:22.000000000 +0300 +++ libdbd-firebird-perl-1.24/debian/changelog 2017-10-07 18:45:00.000000000 +0300 @@ -1,3 +1,10 @@ +libdbd-firebird-perl (1.24-1+deb9u1) stretch; urgency=medium + + * add upstream patch fixing fetching of decimal(x,y) values between -1 and 0 + (Closes: #877720) + + -- Damyan Ivanov <d...@debian.org> Sat, 07 Oct 2017 15:45:00 +0000 + libdbd-firebird-perl (1.24-1) unstable; urgency=medium * New upstream version 1.24 diff -Nru libdbd-firebird-perl-1.24/debian/patches/decimal-fetch-between-minus-one-and-zero.patch libdbd-firebird-perl-1.24/debian/patches/decimal-fetch-between-minus-one-and-zero.patch --- libdbd-firebird-perl-1.24/debian/patches/decimal-fetch-between-minus-one-and-zero.patch 1970-01-01 02:00:00.000000000 +0200 +++ libdbd-firebird-perl-1.24/debian/patches/decimal-fetch-between-minus-one-and-zero.patch 2017-10-07 18:42:15.000000000 +0300 @@ -0,0 +1,37 @@ +b4fad5d264abafeb26e1333b74f6a5c2f75f4869 dbd_st_fetch: fix conversion of numerics between -1 and 0 +diff --git a/dbdimp.c b/dbdimp.c +index 1c48d7c..ff7b510 100644 +--- a/dbdimp.c ++++ b/dbdimp.c +@@ -1431,20 +1431,28 @@ AV *dbd_st_fetch(SV *sth, imp_sth_t *imp_sth) + #endif + if (var->sqlscale == 0) { + snprintf(buf, sizeof(buf), "%"DBD_IB_INT64f, i); ++ sv_setpvn(sv, buf, strlen(buf)); + } else { ++ bool sign = ( i < 0 ); + ISC_INT64 divisor, remainder; + divisor = scales[-var->sqlscale]; ++ if (sign) divisor = -divisor; + remainder = (i%divisor); + if (remainder < 0) remainder = -remainder; + +- snprintf(buf, sizeof(buf), ++ snprintf(buf+1, sizeof(buf)-1, + "%"DBD_IB_INT64f".%0*"DBD_IB_INT64f, + i/divisor, -var->sqlscale, remainder); + DBI_TRACE_imp_xxh(imp_sth, 3, (DBIc_LOGPIO(imp_sth), "-------------->SQLINT64=%"DBD_IB_INT64f".%0*"DBD_IB_INT64f,i/divisor, -var->sqlscale, remainder )); + ++ if (sign) { ++ *buf = '-'; ++ sv_setpvn(sv, buf, strlen(buf)); ++ } ++ else { ++ sv_setpvn(sv, buf+1, strlen(buf+1)); ++ } + } +- +- sv_setpvn(sv, buf, strlen(buf)); + } + break; + #endif diff -Nru libdbd-firebird-perl-1.24/debian/patches/series libdbd-firebird-perl-1.24/debian/patches/series --- libdbd-firebird-perl-1.24/debian/patches/series 1970-01-01 02:00:00.000000000 +0200 +++ libdbd-firebird-perl-1.24/debian/patches/series 2017-10-07 18:42:15.000000000 +0300 @@ -0,0 +1 @@ +decimal-fetch-between-minus-one-and-zero.patch