Skip to content

Commit

Permalink
Add more warnings.
Browse files Browse the repository at this point in the history
These find an old bug-let in hts_parse_format():
The buffer size is 8, but it includes \0 so the string would have been
truncated, causing the strcmp to fail for "fastq.gz".

Curiously gcc 10 and 11 spot this, but not gcc 12 or 13, nor clang.
  • Loading branch information
jkbonfield committed Aug 22, 2024
1 parent 16abf8c commit b5ee95f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ rocky_task:
LC_ALL: C
CIRRUS_CLONE_DEPTH: 1
USE_CONFIG: yes
CFLAGS: -std=gnu90 -Wformat -Wformat=2
CFLAGS: -g -O3 -std=gnu90 -Wformat -Wformat=2 -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-empty-body

# NB: we could consider building a docker image with these
# preinstalled and specifying that instead, to speed up testing.
Expand Down
2 changes: 1 addition & 1 deletion hts.c
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ int hts_parse_opt_list(htsFormat *fmt, const char *str) {
* -1 on failure.
*/
int hts_parse_format(htsFormat *format, const char *str) {
char fmt[8];
char fmt[9];
const char *cp = scan_keyword(str, ',', fmt, sizeof fmt);

format->version.minor = 0; // unknown
Expand Down
1 change: 1 addition & 0 deletions test/test-bcf-sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ int main(int argc, char *argv[])
break;
case 'h':
usage(EXIT_SUCCESS);
// fall-through
default: usage(EXIT_FAILURE);
}
}
Expand Down

0 comments on commit b5ee95f

Please sign in to comment.