Added safeguard for socket path
This commit is contained in:
parent
30266e702b
commit
95bc6e7d33
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue