Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/autofs autofs: Fix segfault that could occur on "au...



details:   https://anonhg.NetBSD.org/src/rev/69b03ad1d943
branches:  trunk
changeset: 465304:69b03ad1d943
user:      tkusumi <tkusumi%NetBSD.org@localhost>
date:      Sat Nov 16 12:21:06 2019 +0000

description:
autofs: Fix segfault that could occur on "automount -LL"

diffstat:

 usr.sbin/autofs/common.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (36 lines):

diff -r 88825b0b55ea -r 69b03ad1d943 usr.sbin/autofs/common.c
--- a/usr.sbin/autofs/common.c  Sat Nov 16 11:56:29 2019 +0000
+++ b/usr.sbin/autofs/common.c  Sat Nov 16 12:21:06 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: common.c,v 1.2 2019/11/16 11:56:29 tkusumi Exp $       */
+/*     $NetBSD: common.c,v 1.3 2019/11/16 12:21:06 tkusumi Exp $       */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  * $FreeBSD: head/usr.sbin/autofs/common.c 303527 2016-07-30 01:10:05Z bapt $
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: common.c,v 1.2 2019/11/16 11:56:29 tkusumi Exp $");
+__RCSID("$NetBSD: common.c,v 1.3 2019/11/16 12:21:06 tkusumi Exp $");
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -357,7 +357,7 @@
                 * of characters before the '&'.
                 */
                before_len = i;
-               //assert(i + 1 < strlen(string));
+               //assert(i < strlen(string));
 
                ret = asprintf(&expanded, "%.*s%s%s",
                    (int)before_len, string, key, string + before_len + 1);
@@ -372,6 +372,8 @@
                 */
                string = expanded;
                i = before_len + strlen(key);
+               if (i == strlen(string))
+                       break;
                backslashed = false;
                //assert(i < strlen(string));
        }



Home | Main Index | Thread Index | Old Index