From ca6bc68adec416837dbae10c2ee9a0e849d77bfc Mon Sep 17 00:00:00 2001 From: d4ndox Date: Thu, 18 Apr 2024 09:12:11 +0200 Subject: [PATCH] replaced stat() with lstat(), which provides information about a file or directory but does not follow symbolic links. This helps to ensure that the status of the file or directory is checked at the time of use, without being influenced by potential changes that may have occurred since the check. --- mnp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mnp.c b/mnp.c index 724a74d..ba37ca3 100644 --- a/mnp.c +++ b/mnp.c @@ -152,7 +152,7 @@ int main(int argc, char **argv) break; case 'o': notify = atoi(optarg); - if (notify >= CONFIRMED) { + if (notify > CONFIRMED) { syslog(LOG_USER | LOG_ERR, "--notify-at out of range [0,1,2]"); fprintf(stderr, "mnp: --notify-at out of range [0,1,2]\n"); closelog(); @@ -681,8 +681,7 @@ static int remove_directory(const char *path) struct stat statbuf; snprintf(buf, len, "%s/%s", path, p->d_name); - - if (!stat(buf, &statbuf)) { + if (!lstat(buf, &statbuf)) { if (S_ISDIR(statbuf.st_mode)) { r2 = remove_directory(buf); } else {