From 47d1d4a9113da9e3df0fc27d8ca0ed69c6c5947f Mon Sep 17 00:00:00 2001 From: Urban Wallasch Date: Sat, 6 Jun 2020 12:54:04 +0200 Subject: [PATCH] * Fix off-by-one in filename generation. --- riffx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/riffx.c b/riffx.c index d71ae66..6533f89 100644 --- a/riffx.c +++ b/riffx.c @@ -363,16 +363,16 @@ int main(int argc, char *argv[]) { *x = 0; if (cfg.use_basename) { x = strrchr(tfn, '/'); - x = x ? x : tfn; + x = x ? x + 1 : tfn; n = snprintf(fpfx, sizeof fpfx, "%s/%03d_%s_", odir, i - argidx, x); } else { n = snprintf(fpfx, sizeof fpfx, "%s/%s/", odir, tfn); } - if ( (size_t)n >= sizeof fpfx ) { - LOG("output directory path truncated: '%s'\n", fpfx); - exit(EXIT_FAILURE); - } + if ( (size_t)n >= sizeof fpfx ) { + LOG("output directory path truncated: '%s'\n", fpfx); + exit(EXIT_FAILURE); + } if (!cfg.use_basename) mkdirp(fpfx, 0755); LOG("Dumping to %s...\n", fpfx); -- 2.30.2