From 1383afcb9927e968b7e8bf1462f513466e99658a Mon Sep 17 00:00:00 2001 From: Edward Tomasz Napierala Date: Wed, 10 Apr 2019 16:09:06 +0000 Subject: [PATCH] Fix segfault that could occur on "automount -LL". MFC after: 2 weeks Sponsored by: DARPA, AFRL --- usr.sbin/autofs/common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.sbin/autofs/common.c b/usr.sbin/autofs/common.c index 65b8737bcff4..ad9e90b850e1 100644 --- a/usr.sbin/autofs/common.c +++ b/usr.sbin/autofs/common.c @@ -365,7 +365,7 @@ expand_ampersand(char *string, const char *key) * of characters before the '&'. */ before_len = i; - //assert(i + 1 < (int)strlen(string)); + //assert(i < (int)strlen(string)); ret = asprintf(&expanded, "%.*s%s%s", before_len, string, key, string + before_len + 1); @@ -380,6 +380,8 @@ expand_ampersand(char *string, const char *key) */ string = expanded; i = before_len + strlen(key); + if (i == (int)strlen(string)) + break; backslashed = false; //assert(i < (int)strlen(string)); }