summaryrefslogtreecommitdiff
blob: cda1cabdc24d44eea2c54d8e4d1276a6ae99d890 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From: Pali <pali@cpan.org>
Date: Fri, 24 Feb 2017 19:51:36 +0100
Subject: [PATCH] Fix type conversions
 Calling SvNV() for magical scalar is not enough for float type conversion.
 It caused problem for Amavis in tainted mode -- all float values were zero.
 On the other hand SvIV() and SvUV() seems to work fine. To be sure that
 correct value of float is in scalar use sv_setnv() with explicit NV float
 value. Similar code is changed also for integers IV/UV.
 .
 This patch should fix reported Amavis bug:
 https://github.com/perl5-dbi/DBD-mysql/issues/78
 .
 See also reported perl bug about SvNV():
 https://rt.perl.org/Public/Bug/Display.html?id=130801
Bugs: https://github.com/perl5-dbi/DBD-mysql/issues/78
Bugs-Debian: https://bugs.debian.org/856064
Last-Update: 2019-01-09
Reviewed-By: Xavier Guimard <x.guimard@free.fr>,
 gregor herrmann <gregoa@debian.org>

--- a/dbdimp.c
+++ b/dbdimp.c
@@ -4447,8 +4447,7 @@
           if (!(fields[i].flags & ZEROFILL_FLAG))
           {
             /* Coerce to double and set scalar as NV */
-            (void) SvNV(sv);
-            SvNOK_only(sv);
+            sv_setnv(sv, SvNV(sv));
           }
           break;
 
@@ -4459,13 +4458,11 @@
             /* Coerce to integer and set scalar as UV resp. IV */
             if (fields[i].flags & UNSIGNED_FLAG)
             {
-              (void) SvUV(sv);
-              SvIOK_only_UV(sv);
+              sv_setuv(sv, SvUV(sv));
             }
             else
             {
-              (void) SvIV(sv);
-              SvIOK_only(sv);
+              sv_setiv(sv, SvIV(sv));
             }
           }
           break;