You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/app-cdr/cdrdao/files/cdrdao-1.2.3-wformat-securi...

174 lines
6.1 KiB

Fix -Werror=format-security errors
Also fix incorrect printf() format specifiers
https://bugs.gentoo.org/show_bug.cgi?id=520988
* gen.c: In function 'genHdr':
* gen.c:3869:17: error: format not a string literal and no format arguments [-Werror=format-security]
--- cdrdao-1.2.3/pccts/antlr/bits.c
+++ cdrdao-1.2.3/pccts/antlr/bits.c
@@ -574,13 +574,13 @@
else
fprintf(DefFile, "extern SetWordType zzerr%d[];\n", esetnum);
if ( name!=NULL ) {
- fprintf(ErrFile, "SetWordType %s%s[%d] = {",
+ fprintf(ErrFile, "SetWordType %s%s[%lu] = {",
name,
suffix,
NumWords(TokenNum-1)*sizeof(unsigned));
}
else {
- fprintf(ErrFile, "SetWordType zzerr%d[%d] = {",
+ fprintf(ErrFile, "SetWordType zzerr%d[%lu] = {",
esetnum,
NumWords(TokenNum-1)*sizeof(unsigned));
}
@@ -642,20 +642,20 @@
esetnum++;
if ( name!=NULL ) {
- fprintf(Parser_h, "\tstatic SetWordType %s%s[%d];\n", name, suffix,
+ fprintf(Parser_h, "\tstatic SetWordType %s%s[%lu];\n", name, suffix,
NumWords(TokenNum-1)*sizeof(unsigned));
- fprintf(Parser_c, "SetWordType %s::%s%s[%d] = {",
+ fprintf(Parser_c, "SetWordType %s::%s%s[%lu] = {",
CurrentClassName,
name,
suffix,
NumWords(TokenNum-1)*sizeof(unsigned));
}
else {
- fprintf(Parser_c, "SetWordType %s::err%d[%d] = {",
+ fprintf(Parser_c, "SetWordType %s::err%d[%lu] = {",
CurrentClassName,
esetnum,
NumWords(TokenNum-1)*sizeof(unsigned));
- fprintf(Parser_h, "\tstatic SetWordType err%d[%d];\n", esetnum,
+ fprintf(Parser_h, "\tstatic SetWordType err%d[%lu];\n", esetnum,
NumWords(TokenNum-1)*sizeof(unsigned));
}
@@ -788,7 +788,7 @@
/* Build constructors */
fprintf(Parser_c, "\n%s::", CurrentClassName);
- fprintf(Parser_c, "%s(ANTLRTokenBuffer *input) : %s(input,%d,%d,%d,%d)\n",
+ fprintf(Parser_c, "%s(ANTLRTokenBuffer *input) : %s(input,%d,%d,%d,%lu)\n",
CurrentClassName,
(BaseClassName == NULL ? "ANTLRParser" : BaseClassName),
OutputLL_k,
@@ -913,7 +913,7 @@
#ifdef DUM
if ( LexGen ) fprintf(ErrFile, "#define zzEOF_TOKEN %d\n", (TokenInd!=NULL?TokenInd[EofToken]:EofToken));
#endif
- fprintf(ErrFile, "#define zzSET_SIZE %d\n", NumWords(TokenNum-1)*sizeof(unsigned));
+ fprintf(ErrFile, "#define zzSET_SIZE %lu\n", NumWords(TokenNum-1)*sizeof(unsigned));
if ( DemandLookahead ) fprintf(ErrFile, "#define DEMAND_LOOK\n");
fprintf(ErrFile, "#include \"antlr.h\"\n");
if ( GenAST ) fprintf(ErrFile, "#include \"ast.h\"\n");
--- cdrdao-1.2.3/pccts/antlr/fset2.c
+++ cdrdao-1.2.3/pccts/antlr/fset2.c
@@ -2210,7 +2210,7 @@
if (p->ntype != nToken) continue;
tn=(TokNode *)p;
if (depth != 0) fprintf(stdout," ");
- fprintf(stdout,TerminalString(tn->token));
+ fprintf(stdout,"%s",TerminalString(tn->token));
depth++;
if (! MR_AmbAidMultiple) {
if (set_nil(tn->tset)) {
--- cdrdao-1.2.3/pccts/antlr/gen.c
+++ cdrdao-1.2.3/pccts/antlr/gen.c
@@ -159,7 +159,7 @@
#define gen6(s,a,b,c,d,e,f) {tab(); fprintf(output, s,a,b,c,d,e,f);}
#define gen7(s,a,b,c,d,e,f,g) {tab(); fprintf(output, s,a,b,c,d,e,f,g);}
-#define _gen(s) {fprintf(output, s);}
+#define _gen(s) {fprintf(output, "%s", s);}
#define _gen1(s,a) {fprintf(output, s,a);}
#define _gen2(s,a,b) {fprintf(output, s,a,b);}
#define _gen3(s,a,b,c) {fprintf(output, s,a,b,c);}
@@ -3911,7 +3911,7 @@
}
#endif
/* ###WARNING: This will have to change when SetWordSize changes */
- if ( !GenCC ) _gen1("#define zzSET_SIZE %d\n", NumWords(TokenNum-1)*sizeof(unsigned));
+ if ( !GenCC ) _gen1("#define zzSET_SIZE %lu\n", NumWords(TokenNum-1)*sizeof(unsigned));
if (TraceGen) {
_gen("#ifndef zzTRACE_RULES\n"); /* MR20 */
_gen("#define zzTRACE_RULES\n"); /* MR20 */
@@ -4125,7 +4125,7 @@
if ( LexGen ) fprintf(f, "#define zzEOF_TOKEN %d\n", (TokenInd!=NULL?TokenInd[EofToken]:EofToken));
#endif
/* ###WARNING: This will have to change when SetWordSize changes */
- fprintf(f, "#define zzSET_SIZE %d\n", NumWords(TokenNum-1)*sizeof(unsigned));
+ fprintf(f, "#define zzSET_SIZE %lu\n", NumWords(TokenNum-1)*sizeof(unsigned));
if (TraceGen) {
fprintf(f,"#ifndef zzTRACE_RULES\n"); /* MR20 */
fprintf(f,"#define zzTRACE_RULES\n"); /* MR20 */
--- cdrdao-1.2.3/pccts/antlr/lex.c
+++ cdrdao-1.2.3/pccts/antlr/lex.c
@@ -706,7 +706,7 @@
/* MR26 */ if (! (isalpha(*t) || isdigit(*t) || *t == '_' || *t == '$')) break;
/* MR26 */ }
/* MR26 */ }
-/* MR26 */ fprintf(output,strBetween(pSymbol, t, pSeparator));
+/* MR26 */ fprintf(output,"%s",strBetween(pSymbol, t, pSeparator));
*q = p;
return (*pSeparator == 0);
@@ -771,7 +771,7 @@
&pValue,
&pSeparator,
&nest);
- fprintf(f,strBetween(pDataType, pSymbol, pSeparator));
+ fprintf(f,"%s",strBetween(pDataType, pSymbol, pSeparator));
}
/* check to see if string e is a word in string s */
@@ -852,9 +852,9 @@
&pSeparator,
&nest);
fprintf(f,"\t");
- fprintf(f,strBetween(pDataType, pSymbol, pSeparator));
+ fprintf(f,"%s",strBetween(pDataType, pSymbol, pSeparator));
fprintf(f," ");
- fprintf(f,strBetween(pSymbol, pEqualSign, pSeparator));
+ fprintf(f,"%s",strBetween(pSymbol, pEqualSign, pSeparator));
fprintf(f,";\n");
}
fprintf(f,"};\n");
--- cdrdao-1.2.3/pccts/antlr/set.c
+++ cdrdao-1.2.3/pccts/antlr/set.c
@@ -263,7 +263,7 @@
static set a;
if ( b == nil ) return( empty );
- set_new(a, b);
+ set_new(a, (long unsigned int) b);
a.setword[DIVWORD(b)] = bitmask[MODWORD(b)];
return(a);
--- cdrdao-1.2.3/pccts/dlg/set.c
+++ cdrdao-1.2.3/pccts/dlg/set.c
@@ -263,7 +263,7 @@
static set a;
if ( b == nil ) return( empty );
- set_new(a, b);
+ set_new(a, (long unsigned int) b);
a.setword[DIVWORD(b)] = bitmask[MODWORD(b)];
return(a);
--- cdrdao-1.2.3/pccts/h/set.h
+++ cdrdao-1.2.3/pccts/h/set.h
@@ -55,7 +55,7 @@
/* make arg1 a set big enough to hold max elem # of arg2 */
#define set_new(a,_max) \
if (((a).setword=(unsigned *)calloc(NumWords(_max),BytesPerWord))==NULL) \
- fprintf(stderr, "set_new: Cannot allocate set with max of %d\n", _max); \
+ fprintf(stderr, "set_new: Cannot allocate set with max of %lu\n", _max); \
(a).n = NumWords(_max);
#define set_free(a) \