Module Name: src Committed By: kamil Date: Sun Jun 14 01:26:46 UTC 2020
Modified Files: src/usr.bin/jot: jot.c Log Message: Generate format after setting the prec value Otherwise we end up with setting invalid printf format: "%.-1f" (from "if (snprintf(p, sz, "%%.%df", prec) >= (int)sz)") for prec equal to -1, which is not canonical (rejected by gcc and clang when used explicitly). Detected by ASan (MKSANITIZER) for "jot 8". To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/usr.bin/jot/jot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/jot/jot.c diff -u src/usr.bin/jot/jot.c:1.27 src/usr.bin/jot/jot.c:1.28 --- src/usr.bin/jot/jot.c:1.27 Sun Feb 3 03:19:29 2019 +++ src/usr.bin/jot/jot.c Sun Jun 14 01:26:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: jot.c,v 1.27 2019/02/03 03:19:29 mrg Exp $ */ +/* $NetBSD: jot.c,v 1.28 2020/06/14 01:26:46 kamil Exp $ */ /*- * Copyright (c) 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993\ #if 0 static char sccsid[] = "@(#)jot.c 8.1 (Berkeley) 6/6/93"; #endif -__RCSID("$NetBSD: jot.c,v 1.27 2019/02/03 03:19:29 mrg Exp $"); +__RCSID("$NetBSD: jot.c,v 1.28 2020/06/14 01:26:46 kamil Exp $"); #endif /* not lint */ /* @@ -226,11 +226,12 @@ getargs(int argc, char *argv[]) errx(EXIT_FAILURE, "Too many arguments. What do you mean by %s?", argv[4]); } - getformat(); if (prec == -1) prec = 0; + getformat(); + if (randomize) { /* 'step' is the seed here, use pseudo-random default */ if (!(have & STEP))