From ce39e8e6fa1d8220e4050219ad72dfdc77ee1cfc Mon Sep 17 00:00:00 2001 From: David Phillips Date: Tue, 26 Apr 2016 16:15:12 +1200 Subject: Fix snprintf overflow detection, add newline to error message --- cue-bin-split.c | 2 +- misc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cue-bin-split.c b/cue-bin-split.c index 4ebd843..2e2a190 100644 --- a/cue-bin-split.c +++ b/cue-bin-split.c @@ -141,7 +141,7 @@ int main(int argc, char **argv) if (start_sample > finish_sample) { - fprintf(stderr, "ERROR: Finish time can't be before start time, skipping %s", out_fname); + fprintf(stderr, "ERROR: Finish time can't be before start time, skipping %s\n", out_fname); continue; } diff --git a/misc.c b/misc.c index 7ee275a..1515a7d 100644 --- a/misc.c +++ b/misc.c @@ -56,7 +56,7 @@ double get_sec() */ int construct_out_name(char *buffer, size_t buffer_size, char* format, unsigned int track) { - if (snprintf(buffer, buffer_size, format, track) == buffer_size) + if (snprintf(buffer, buffer_size, format, track) >= buffer_size - 1) { fprintf(stderr, "Filename too large for buffer (max %zd)\n", buffer_size); return -1; -- cgit v1.1