Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/jot Generate format after setting the prec value
details: https://anonhg.NetBSD.org/src/rev/fc74b696e98f
branches: trunk
changeset: 972940:fc74b696e98f
user: kamil <kamil%NetBSD.org@localhost>
date: Sun Jun 14 01:26:46 2020 +0000
description:
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".
diffstat:
usr.bin/jot/jot.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diffs (32 lines):
diff -r 5815ae7e1f18 -r fc74b696e98f usr.bin/jot/jot.c
--- a/usr.bin/jot/jot.c Sun Jun 14 00:30:20 2020 +0000
+++ b/usr.bin/jot/jot.c Sun Jun 14 01:26:46 2020 +0000
@@ -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 @@
#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 @@
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))
Home |
Main Index |
Thread Index |
Old Index