svn commit: r339122 - stable/11/libexec/rtld-elf

Konstantin Belousov kib at FreeBSD.org
Wed Oct 3 11:34:29 UTC 2018


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 *


More information about the svn-src-stable-11 mailing list