Skip to contentSkip to conversation

There is a bug on parsing file path in auditd-config.c and audispd-pconfig.c

PATCH wangf 1 participant 1 message Jul 1, 2008

lore
Share & tools
lore

wangf

author
#0 lore raw

Hi Steve,

There is a bug in function dispatch_parser() and path_parser().

when we use dir = dirname (tdir), if tdir is not NULL, tdir and dir point to the same addr., so if we use free(tdir) before audit_msg(LOG_ERR, "The directory name: %s is too short - line %d", dir, line); we can not get the dir's correct value.

This patch can solve this problem.

---

audisp/audispd-pconfig.c +0 -0
diff -Nrup audit-1.7.4/audisp/audispd-pconfig.c audit-1.7.4-new/audisp/audispd-pconfig.c
@@ -379,10 +379,10 @@ static int path_parser(struct nv_pair *n
	if (tdir)
		dir = dirname(tdir);
	if (dir == NULL || strlen(dir) < 4) { //  '/var' is shortest dirname
-		free(tdir);
		audit_msg(LOG_ERR,
			"The directory name: %s is too short - line %d",
			dir, line);
+		free(tdir);
		return 1;
	}
src/auditd-config.c +0 -0
diff -Nrup audit-1.7.4/src/auditd-config.c audit-1.7.4-new/src/auditd-config.c
@@ -592,10 +592,10 @@ static int dispatch_parser(struct nv_pai
	if (tdir)
		dir = dirname(tdir);
	if (dir == NULL || strlen(dir) < 4) { //  '/var' is shortest dirname
-		free(tdir);
		audit_msg(LOG_ERR,
			"The directory name: %s is too short - line %d",
			dir, line);
+		free(tdir);
		return 1;
	}

--
Best Regards,
Wang Fang