Fix buffer overflow

This commit is contained in:
EnderIce2 2024-03-19 17:05:26 +02:00
parent 2c57714eda
commit ecba9ee5d7
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD

View File

@ -493,13 +493,13 @@ char *create_file()
if (p == NULL)
{
path = malloc(20);
path = malloc(24);
sprintf(path, "/tmp/watched_file.txt");
fp = fopen(path, "w");
}
else
{
path = malloc(strlen(p->pw_dir) + 20);
path = malloc(strlen(p->pw_dir) + 24);
sprintf(path, "%s/watched_file.txt", p->pw_dir);
fp = fopen(path, "w");
}
@ -521,12 +521,12 @@ char *create_directory()
if (p == NULL)
{
path = malloc(20);
path = malloc(24);
sprintf(path, "/tmp/watched_directory");
}
else
{
path = malloc(strlen(p->pw_dir) + 20);
path = malloc(strlen(p->pw_dir) + 24);
sprintf(path, "%s/watched_directory", p->pw_dir);
}