summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authormdodd <mdodd@FreeBSD.org>2003-05-30 00:49:16 +0000
committermdodd <mdodd@FreeBSD.org>2003-05-30 00:49:16 +0000
commitde8f54e71ea2e367332b9a7905c11a37ac754421 (patch)
tree976674c44e42dcd1cbdb606fea09cc8b361d0794 /libexec
parenta22cad65ccb9cfd81c057db83cc2c7c2cb5ae79d (diff)
downloadFreeBSD-src-de8f54e71ea2e367332b9a7905c11a37ac754421.zip
FreeBSD-src-de8f54e71ea2e367332b9a7905c11a37ac754421.tar.gz
Don't post-increment pointers inside a loop conditional.
While I'm here: - Let lm_add() call strdup() on its own behalf. - Use a temporary pointer when parsing constraints; only set the constraint pointer on a totally successful match. PR: bin/52783 Submitted by: David P. Reese Jr. <daver@gomerbud.com> Approved by: re (rwatson)
Diffstat (limited to 'libexec')
-rw-r--r--libexec/rtld-elf/libmap.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/libexec/rtld-elf/libmap.c b/libexec/rtld-elf/libmap.c
index 13fa888..f5dd372 100644
--- a/libexec/rtld-elf/libmap.c
+++ b/libexec/rtld-elf/libmap.c
@@ -31,7 +31,7 @@ struct lmp {
TAILQ_ENTRY(lmp) lmp_link;
};
-static void lm_add (char *, char *, char *);
+static void lm_add (const char *, const char *, const char *);
static void lm_free (struct lm_list *);
static char * lml_find (struct lm_list *, const char *);
static struct lm_list * lmp_find (const char *);
@@ -45,7 +45,7 @@ lm_init (void)
{
FILE *fp;
char *cp;
- char *f, *t, *p;
+ char *f, *t, *p, *c;
char prog[MAXPATHLEN];
char line[MAXPATHLEN + 2];
@@ -56,7 +56,7 @@ lm_init (void)
p = NULL;
while ((cp = fgets(line, MAXPATHLEN + 1, fp)) != NULL) {
- t = f = NULL;
+ t = f = c = NULL;
/* Skip over leading space */
while (isspace(*cp)) cp++;
@@ -75,7 +75,7 @@ lm_init (void)
if (iseol(*cp) || *cp == ']')
continue;
- p = cp++;
+ c = cp++;
/* Skip to end of word */
while (!isspace(*cp) && !iseol(*cp) && *cp != ']')
cp++;
@@ -93,10 +93,10 @@ lm_init (void)
* There should be nothing except whitespace or comment
from this point to the end of the line.
*/
- while(isspace(*cp++));
+ while(isspace(*cp)) *cp++;
if (!iseol(*cp)) continue;
- strcpy(prog, p);
+ strcpy(prog, c);
p = prog;
continue;
}
@@ -122,7 +122,7 @@ lm_init (void)
if (!iseol(*cp)) continue;
*cp = '\0';
- lm_add(p, xstrdup(f), xstrdup(t));
+ lm_add(p, f, t);
}
fclose(fp);
return;
@@ -159,7 +159,7 @@ lm_fini (void)
}
static void
-lm_add (char *p, char *f, char *t)
+lm_add (const char *p, const char *f, const char *t)
{
struct lm_list *lml;
struct lm *lm;
@@ -171,8 +171,8 @@ lm_add (char *p, char *f, char *t)
lml = lmp_init(xstrdup(p));
lm = xmalloc(sizeof(struct lm));
- lm->f = f;
- lm->t = t;
+ lm->f = xstrdup(f);
+ lm->t = xstrdup(t);
TAILQ_INSERT_HEAD(lml, lm, lm_link);
}
@@ -189,7 +189,7 @@ lm_find (const char *p, const char *f)
* Add a global mapping if we have
* a successful constrained match.
*/
- lm_add(NULL, xstrdup(f), xstrdup(t));
+ lm_add(NULL, f, t);
return (t);
}
}
OpenPOWER on IntegriCloud