From: tb Date: Fri, 13 Aug 2021 10:40:23 +0000 (+0000) Subject: Make sure prec is non-negative before calling getformat() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8b5f200da98efc14f8d43af38cd9e76fcbba9b46;p=openbsd Make sure prec is non-negative before calling getformat() If jot is called without arguments, getformat() produces the illegal "%.-1f" format string. __vfprintf() misinterprets the - as a left adjust flag and uses a precision of 0. Set prec = 0 so that we use "%.0f" in this situation. ok martijn --- diff --git a/usr.bin/jot/jot.c b/usr.bin/jot/jot.c index 62eaf5d14e2..fd686d40a6e 100644 --- a/usr.bin/jot/jot.c +++ b/usr.bin/jot/jot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: jot.c,v 1.52 2021/08/13 07:56:34 martijn Exp $ */ +/* $OpenBSD: jot.c,v 1.53 2021/08/13 10:40:23 tb Exp $ */ /* $NetBSD: jot.c,v 1.3 1994/12/02 20:29:43 pk Exp $ */ /*- @@ -160,10 +160,10 @@ main(int argc, char *argv[]) mask |= REPS; if (reps == 0) infinity = true; - if (prec == -1) - prec = 0; } case 0: + if (prec == -1) + prec = 0; break; default: errx(1, "Too many arguments. What do you mean by %s?",