From: Urban Wallasch Date: Sat, 6 Jun 2020 10:54:04 +0000 (+0200) Subject: * Fix off-by-one in filename generation. X-Git-Url: https://git.packet-gain.de/?a=commitdiff_plain;ds=sidebyside;p=riffx.git * Fix off-by-one in filename generation. --- 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);