From: tb Date: Fri, 5 Aug 2016 13:33:21 +0000 (+0000) Subject: If "%%" appears in the format string, skip it properly. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ac2d47dbb48a029808eccbc0f36a4e97bb79c064;p=openbsd If "%%" appears in the format string, skip it properly. Part of pjanzen's fixes in r1.8, but was lost in r1.17. Fixes regression tests wp3, wp4, wp5. 'good direction' deraadt --- diff --git a/usr.bin/jot/jot.c b/usr.bin/jot/jot.c index 62771001714..19bd6600412 100644 --- a/usr.bin/jot/jot.c +++ b/usr.bin/jot/jot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: jot.c,v 1.29 2016/08/05 13:21:31 tb Exp $ */ +/* $OpenBSD: jot.c,v 1.30 2016/08/05 13:33:21 tb Exp $ */ /* $NetBSD: jot.c,v 1.3 1994/12/02 20:29:43 pk Exp $ */ /*- @@ -394,8 +394,11 @@ getformat(void) if (boring) /* no need to bother */ return; for (p = format; *p != '\0'; p++) /* look for '%' */ - if (*p == '%' && *(p+1) != '%') /* leave %% alone */ - break; + if (*p == '%') { + if (*(p+1) != '%') + break; + p++; /* leave %% alone */ + } sz = sizeof(format) - strlen(format) - 1; if (*p == '\0' && !chardata) { int n;