forked from hkc/sfxd
1
0
Fork 0

Added safeguard for socket path

This commit is contained in:
Casey 2024-02-25 13:41:00 +03:00
parent 30266e702b
commit 95bc6e7d33
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
1 changed files with 9 additions and 0 deletions

View File

@ -1,5 +1,6 @@
#include "common.h"
#include "miniaudio.h"
#include <errno.h>
#include <getopt.h>
#include <limits.h>
#include <stdarg.h>
@ -9,6 +10,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/un.h>
#include <unistd.h>
@ -105,6 +107,13 @@ int main(int argc, char **argv) {
}
}
{
struct stat statbuf;
int status = stat(sock_path, &statbuf);
if (status == 0 && !S_ISSOCK(statbuf.st_mode)) {
PANIC("Specified sock_path is not a socket");
}
}
if (!ipc_init(sock_path)) {
unlink(sock_path);