Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Oct 2018 11:34:28 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r339122 - stable/11/libexec/rtld-elf
Message-ID:  <201810031134.w93BYSLK032662@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Wed Oct  3 11:34:28 2018
New Revision: 339122
URL: https://svnweb.freebsd.org/changeset/base/339122

Log:
  MFC r338955:
  When doing lm_add(), check for duplicates.

Modified:
  stable/11/libexec/rtld-elf/libmap.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/libexec/rtld-elf/libmap.c
==============================================================================
--- stable/11/libexec/rtld-elf/libmap.c	Wed Oct  3 07:35:16 2018	(r339121)
+++ stable/11/libexec/rtld-elf/libmap.c	Wed Oct  3 11:34:28 2018	(r339122)
@@ -350,6 +350,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$";
@@ -359,11 +360,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?201810031134.w93BYSLK032662>