Skip to content

Commit

Permalink
replaced stat() with lstat(), which provides
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
d4ndox committed Apr 18, 2024
1 parent c42ee6c commit ca6bc68
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ca6bc68

Please sign in to comment.