Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Sep 2018 21:27:08 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r338955 - head/libexec/rtld-elf
Message-ID:  <201809262127.w8QLR8dv024454@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Wed Sep 26 21:27:08 2018
New Revision: 338955
URL: https://svnweb.freebsd.org/changeset/base/338955

Log:
  When doing lm_add(), check for duplicates.
  
  This is useful when lm_find() moves the match to the global mapping,
  since lm_find() could be called with a same path more than once.
  
  Reported and tested by:	Andreas Longwitz <longwitz@incore.de>
  Sponsored by:	The FreeBSD Foundation
  Approved by:	re (gjb)
  MFC after:	1 week

Modified:
  head/libexec/rtld-elf/libmap.c

Modified: head/libexec/rtld-elf/libmap.c
==============================================================================
--- head/libexec/rtld-elf/libmap.c	Wed Sep 26 21:16:07 2018	(r338954)
+++ head/libexec/rtld-elf/libmap.c	Wed Sep 26 21:27:08 2018	(r338955)
@@ -353,6 +353,7 @@ lm_add(const char *p, const char *f, const char *t)
 {
 	struct lm_list *lml;
 	struct lm *lm;
+	const char *t1;
 
 	if (p == NULL)
 		p = "$DEFAULT$";
@@ -362,11 +363,14 @@ lm_add(const char *p, const char *f, const char *t)
 	if ((lml = lmp_find(p)) == NULL)
 		lml = lmp_init(xstrdup(p));
 
-	lm = xmalloc(sizeof(struct lm));
-	lm->f = xstrdup(f);
-	lm->t = xstrdup(t);
-	TAILQ_INSERT_HEAD(lml, lm, lm_link);
-	lm_count++;
+	t1 = lml_find(lml, f);
+	if (t1 == NULL || strcmp(t1, t) != 0) {
+		lm = xmalloc(sizeof(struct lm));
+		lm->f = xstrdup(f);
+		lm->t = xstrdup(t);
+		TAILQ_INSERT_HEAD(lml, lm, lm_link);
+		lm_count++;
+	}
 }
 
 char *



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