dentearl / mafTools

Bioinformatics tools for dealing with Multiple Alignment Format (MAF) files.
Other
104 stars 32 forks source link

mafToFastaStitcher compilation error #33

Open francicco opened 1 year ago

francicco commented 1 year ago

Hi,

I'm having a problem compiling mafToFastaStitcher.

I'm getting this error

src/mafToFastaStitcherAPI.c:655:22: error: ‘%lu’ directive writing between 1 and 19 bytes into a region of size 7 [-Werror=format-overflow=]
     sprintf(fmtName, " %%-%" PRIu64 "s", maxName + 2);
                      ^~~~~~~
src/mafToFastaStitcherAPI.c:655:27: note: format string is defined here
     sprintf(fmtName, " %%-%" PRIu64 "s", maxName + 2);
src/mafToFastaStitcherAPI.c:655:22: note: directive argument in the range [3, 9223372036854775808]
     sprintf(fmtName, " %%-%" PRIu64 "s", maxName + 2);
                      ^~~~~~~
src/mafToFastaStitcherAPI.c:655:5: note: ‘sprintf’ output between 6 and 24 bytes into a destination of size 10
     sprintf(fmtName, " %%-%" PRIu64 "s", maxName + 2);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Can you help? Thanks a lot Francesco

andrewSharo commented 1 year ago

I'm getting the exact same error!

rsharris commented 1 year ago

@francicco @andrewSharo I have nothing to do with this package. But the error you're getting appears to have resulted from a newer compiler being better able to detect potential errors.

THE FOLLOWING MIGHT NOT BE CORRECT, AND IS OFFERED ONLY AS A SUGGESTION FOR YOU TO CONSIDER. Having looked at neither the source code nor the makefile, I'd suggest you either need to (a) modify mafToFastaStitcherAPI.c so that fmtName is big enough to hold the string that might be generated (I guess you would need a 25-byte character array), or (b) modify the makefile so the compiler will ignore that type of presumed error.

See here for more info: https://stackoverflow.com/questions/51697753/how-to-suppress-sprintf-warning-directive-writing-between-1-and-11-bytes-into

andrewSharo commented 1 year ago

Thanks @rsharris !

I can confirm that changing line 626 of mafToFastaStitcherAPI.c from

char fmtName[10] = "\0", fmtStart[32] = "\0", fmtLen[32] = "\0", fmtSource[32] = "\0", *fmtLine = NULL;

to

char fmtName[32] = "\0", fmtStart[32] = "\0", fmtLen[32] = "\0", fmtSource[32] = "\0", *fmtLine = NULL;

allowed the program to compile. To clarify, just changing 10 to 32. I have not yet checked if it actually runs.

Best, Andrew