summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authortobias@openbsd.org <tobias@openbsd.org>2015-12-04 21:51:06 +0000
committerDamien Miller <djm@mindrot.org>2015-12-07 12:38:59 +1100
commit8b56e59714d87181505e4678f0d6d39955caf10e (patch)
tree24507377b831df2b1c979ec3927695f9d083b009 /misc.c
parent76c9fbbe35aabc1db977fb78e827644345e9442e (diff)
upstream commit
Properly handle invalid %-format by calling fatal. ok deraadt, djm Upstream-ID: 5692bce7d9f6eaa9c488cb93d3b55e758bef1eac
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/misc.c b/misc.c
index b358a035e..9d11d2832 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.c,v 1.99 2015/10/24 08:34:09 sthen Exp $ */ 1/* $OpenBSD: misc.c,v 1.100 2015/12/04 21:51:06 tobias Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved. 4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved.
@@ -604,6 +604,8 @@ percent_expand(const char *string, ...)
604 /* %% case */ 604 /* %% case */
605 if (*string == '%') 605 if (*string == '%')
606 goto append; 606 goto append;
607 if (*string == '\0')
608 fatal("%s: invalid format", __func__);
607 for (j = 0; j < num_keys; j++) { 609 for (j = 0; j < num_keys; j++) {
608 if (strchr(keys[j].key, *string) != NULL) { 610 if (strchr(keys[j].key, *string) != NULL) {
609 i = strlcat(buf, keys[j].repl, sizeof(buf)); 611 i = strlcat(buf, keys[j].repl, sizeof(buf));