Subject: | compilation fails with -Werror=format-security |
$ gcc -c -I. -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fomit-frame-pointer -march=i586 -mtune=generic -fasynchronous-unwind-tables -Wl,--as-needed -Wl,-z,relro -Wl,-O1 -Wl,--build-id -Wl,--enable-new-dtags -pthread -DVERSION=\"0.29\" -DXS_VERSION=\"0.29\" -fPIC "-I/usr/lib/perl5/5.18.0/i386-linux-thread-multi/CORE" -DINT64_BACKEND_NV Int64.c
Int64.xs: In function 'SvI64':
Int64.xs:303:18: warning: this decimal constant is unsigned only in ISO C90 [enabled by default]
Int64.xs:303:18: warning: this decimal constant is unsigned only in ISO C90 [enabled by default]
Int64.xs: In function 'BER_to_uint64':
Int64.xs:546:13: error: format not a string literal and no format arguments [-Werror=format-security]
Int64.xs:550:5: error: format not a string literal and no format arguments [-Werror=format-security]
Int64.xs: In function 'XS_Math__Int64_net_to_int64':
Int64.xs:649:5: error: format not a string literal and no format arguments [-Werror=format-security]
[...]
attached patch fixes the problem.
Subject: | Math-Int64-0.29-fix_format_security.patch |
--- Int64.xs.orig 2013-05-29 09:08:54.444014117 +0200
+++ Int64.xs 2013-05-29 09:12:10.154231481 +0200
@@ -543,11 +543,11 @@
overflow(aTHX_ out_of_bounds_error_u);
a = (a << 7) | (pv[i] & 0x7f);
if ((pv[i] & 0x80) == 0) {
- if (i + 1 != len) Perl_croak(aTHX_ invalid_BER_error);
+ if (i + 1 != len) Perl_croak("%s", aTHX_ invalid_BER_error);
return a;
}
}
- Perl_croak(aTHX_ invalid_BER_error);
+ Perl_croak("%s", aTHX_ invalid_BER_error);
return 0; /* this dead code is a workaround for OpenWatcom */
}
@@ -646,7 +646,7 @@
unsigned char *pv = (unsigned char *)SvPVbyte(net, len);
int64_t i64;
CODE:
- if (len != 8) Perl_croak(aTHX_ invalid_length_error_s);
+ if (len != 8) Perl_croak("%s", aTHX_ invalid_length_error_s);
i64 = (((((((((((((((int64_t)pv[0]) << 8)
+ (int64_t)pv[1]) << 8)
+ (int64_t)pv[2]) << 8)
@@ -670,7 +670,7 @@
uint64_t u64;
CODE:
if (len != 8)
- Perl_croak(aTHX_ invalid_length_error_u);
+ Perl_croak("%s", aTHX_ invalid_length_error_u);
u64 = (((((((((((((((uint64_t)pv[0]) << 8)
+ (uint64_t)pv[1]) << 8)
+ (uint64_t)pv[2]) << 8)
@@ -761,7 +761,7 @@
char *pv = SvPVbyte(native, len);
CODE:
if (len != 8)
- Perl_croak(aTHX_ invalid_length_error_s);
+ Perl_croak("%s", aTHX_ invalid_length_error_s);
if (use_native) {
RETVAL = newSViv(0);
Copy(pv, &(SvIVX(RETVAL)), 8, char);
@@ -792,7 +792,7 @@
char *pv = SvPVbyte(native, len);
CODE:
if (len != 8)
- Perl_croak(aTHX_ invalid_length_error_u);
+ Perl_croak("%s", aTHX_ invalid_length_error_u);
if (use_native) {
RETVAL = newSVuv(0);
Copy(pv, &(SvUVX(RETVAL)), 8, char);
@@ -1098,13 +1098,13 @@
down = SvI64(aTHX_ other);
}
if (!down)
- Perl_croak(aTHX_ div_by_0_error);
+ Perl_croak("%s", aTHX_ div_by_0_error);
RETVAL = newSVi64(aTHX_ up/down);
}
else {
down = SvI64(aTHX_ other);
if (!down)
- Perl_croak(aTHX_ div_by_0_error);
+ Perl_croak("%s", aTHX_ div_by_0_error);
RETVAL = self;
SvREFCNT_inc(RETVAL);
SvI64x(self) /= down;
@@ -1131,13 +1131,13 @@
down = SvI64(aTHX_ other);
}
if (!down)
- Perl_croak(aTHX_ div_by_0_error);
+ Perl_croak("%s", aTHX_ div_by_0_error);
RETVAL = newSVi64(aTHX_ up % down);
}
else {
down = SvI64(aTHX_ other);
if (!down)
- Perl_croak(aTHX_ div_by_0_error);
+ Perl_croak("%s", aTHX_ div_by_0_error);
RETVAL = self;
SvREFCNT_inc(RETVAL);
SvI64x(self) %= down;
@@ -1222,7 +1222,7 @@
}
else sign = 1;
if (b < 0) {
- if (a == 0) Perl_croak(aTHX_ div_by_0_error);
+ if (a == 0) Perl_croak("%s", aTHX_ div_by_0_error);
else if (a == 1) r = sign;
else r = 0;
}
@@ -1592,13 +1592,13 @@
down = SvU64(aTHX_ other);
}
if (!down)
- Perl_croak(aTHX_ div_by_0_error);
+ Perl_croak("%s", aTHX_ div_by_0_error);
RETVAL = newSVu64(aTHX_ up/down);
}
else {
down = SvU64(aTHX_ other);
if (!down)
- Perl_croak(aTHX_ div_by_0_error);
+ Perl_croak("%s", aTHX_ div_by_0_error);
RETVAL = self;
SvREFCNT_inc(RETVAL);
SvU64x(self) /= down;
@@ -1625,13 +1625,13 @@
down = SvU64(aTHX_ other);
}
if (!down)
- Perl_croak(aTHX_ div_by_0_error);
+ Perl_croak("%s", aTHX_ div_by_0_error);
RETVAL = newSVu64(aTHX_ up % down);
}
else {
down = SvU64(aTHX_ other);
if (!down)
- Perl_croak(aTHX_ div_by_0_error);
+ Perl_croak("%s", aTHX_ div_by_0_error);
RETVAL = self;
SvREFCNT_inc(RETVAL);
SvU64x(self) %= down;