Hi Steve,
  I think such codes about "basename" in auditd-config.c and audispd-pconfig.c
is unnecessary. In these part "nv->value" can't be null and "basename()" will
never return an empty string. And the variable "base" is not used in the 
following
codes. So such codes are better to be deleted.

Signed-off-by: Chu Li <[EMAIL PROTECTED]>
---
diff --git a/src/auditd-config.c b/src/auditd-config.c
index 8977502..ca3d3a3 100644
--- a/src/auditd-config.c
+++ b/src/auditd-config.c
@@ -434,14 +434,14 @@ static const struct kw_pair *kw_lookup(const char *val)
 static int log_file_parser(struct nv_pair *nv, int line,
        struct daemon_conf *config)
 {
-       char *dir = NULL, *tdir, *base;
+       char *dir = NULL, *tdir;
        DIR *d;
        int fd, mode;
        struct stat buf;

        audit_msg(LOG_DEBUG, "log_file_parser called with: %s", nv->value);

-       /* split name into dir and basename. */
+       /* get dir from name. */
        tdir = strdup(nv->value);
        if (tdir)
                dir = dirname(tdir);
@@ -453,14 +453,6 @@ static int log_file_parser(struct nv_pair *nv, int line,
                return 1;
        }

-       base = basename((char *)nv->value);
-       if (base == 0 || strlen(base) == 0) {
-               audit_msg(LOG_ERR, "The file name: %s is too short - line %d",
-                       base, line);
-               free((void *)tdir);
-               return 1;
-       }
-
        /* verify the directory path exists */
        d = opendir(dir);
        if (d == NULL) {
@@ -577,7 +569,7 @@ static int qos_parser(struct nv_pair *nv, int line,
 static int dispatch_parser(struct nv_pair *nv, int line,
        struct daemon_conf *config)
 {
-       char *dir = NULL, *tdir, *base;
+       char *dir = NULL, *tdir;
        int fd;
        struct stat buf;

@@ -587,7 +579,7 @@ static int dispatch_parser(struct nv_pair *nv, int line,
                return 0;
        }

-       /* split name into dir and basename. */
+       /* get dir from name. */
        tdir = strdup(nv->value);
        if (tdir)
                dir = dirname(tdir);
@@ -600,12 +592,6 @@ static int dispatch_parser(struct nv_pair *nv, int line,
        }

        free((void *)tdir);
-       base = basename((char *)nv->value);
-       if (base == 0 || strlen(base) == 0) {
-               audit_msg(LOG_ERR, "The file name: %s is too short - line %d",
-                       base, line);
-               return 1;
-       }
        /* if the file exists, see that its regular, owned by root,
         * and not world anything */
        fd = open(nv->value, O_RDONLY);

diff --git a/audisp/audispd-pconfig.c b/audisp/audispd-pconfig.c
index 63b3307..c630a00 100644
--- a/audisp/audispd-pconfig.c
+++ b/audisp/audispd-pconfig.c
@@ -361,7 +361,7 @@ static int direction_parser(struct nv_pair *nv, int line,
 static int path_parser(struct nv_pair *nv, int line,
        plugin_conf_t *config)
 {
-       char *dir = NULL, *tdir, *base;
+       char *dir = NULL, *tdir;
        struct stat buf;

        if (nv->value == NULL) {
@@ -374,7 +374,7 @@ static int path_parser(struct nv_pair *nv, int line,
                return 0;
        }

-       /* split name into dir and basename. */
+       /* get dir form name. */
        tdir = strdup(nv->value);
        if (tdir)
                dir = dirname(tdir);
@@ -387,12 +387,6 @@ static int path_parser(struct nv_pair *nv, int line,
        }

        free((void *)tdir);
-       base = basename((char *)nv->value);
-       if (base == 0 || strlen(base) == 0) {
-               audit_msg(LOG_ERR, "The file name: %s is too short - line %d",
-                       base, line);
-               return 1;
-       }
        /* If the file exists, see that its regular, owned by root,
         * and not world anything */
        if (stat(nv->value, &buf) < 0) {

Regards
Chu Li


Regards
Chu Li



--
Linux-audit mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/linux-audit

Reply via email to