Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 03 Sep 2019 14:06:43 -0000
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r346086 - head/usr.sbin/autofs
Message-ID:  <201904101609.x3AG96FI009094@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Wed Apr 10 16:09:06 2019
New Revision: 346086
URL: https://svnweb.freebsd.org/changeset/base/346086

Log:
  Fix segfault that could occur on "automount -LL".
  
  MFC after:	2 weeks
  Sponsored by:	DARPA, AFRL

Modified:
  head/usr.sbin/autofs/common.c

Modified: head/usr.sbin/autofs/common.c
==============================================================================
--- head/usr.sbin/autofs/common.c	Wed Apr 10 15:38:53 2019	(r346085)
+++ head/usr.sbin/autofs/common.c	Wed Apr 10 16:09:06 2019	(r346086)
@@ -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));
 	}





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904101609.x3AG96FI009094>