Skip to content

Commit 723f46d

Browse files
committed
conf: Return an error if zlog_init is called with a non-regular file
Currently, calling zlog_init with a non-regular file (e.g., a directory) didn’t return an error. The logger would have been configured the same as with an empty file. The file is now checked to ensure it is regular, and an error is returned if it is not. Fixes #278.
1 parent ee835a1 commit 723f46d

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/conf.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,12 @@ static int zlog_conf_build_with_file(zlog_conf_t * a_conf)
476476
errno);
477477
return -1;
478478
}
479+
480+
if (!S_ISREG(a_stat.st_mode)) {
481+
zc_error("conf file[%s] is not a regular file", a_conf->file);
482+
return -1;
483+
}
484+
479485
localtime_r(&(a_stat.st_mtime), &local_time);
480486
strftime(a_conf->mtime, sizeof(a_conf->mtime), "%Y-%m-%d %H:%M:%S", &local_time);
481487

0 commit comments

Comments
 (0)