Fixed buffer length

This commit is contained in:
buffet 2018-10-29 11:57:05 +01:00
parent 7e74bffdd6
commit a007496600
2 changed files with 3 additions and 3 deletions

View file

@ -29,9 +29,9 @@ init_socket(void)
char *sock_path = getenv(SOCK_ENV_VAR); char *sock_path = getenv(SOCK_ENV_VAR);
if (sock_path) { if (sock_path) {
strncpy(sock_addr.sun_path, sock_path, sizeof(sock_addr.sun_path)); strncpy(sock_addr.sun_path, sock_path, sizeof(sock_addr.sun_path) - 1);
} else { } else {
strncpy(sock_addr.sun_path, SOCK_DEF_PATH, sizeof(sock_addr.sun_path)); strncpy(sock_addr.sun_path, SOCK_DEF_PATH, sizeof(sock_addr.sun_path) - 1);
} }
sock_addr.sun_family = AF_UNIX; sock_addr.sun_family = AF_UNIX;

View file

@ -51,7 +51,7 @@ main(int argc, char *argv[])
printf("v" VERSION_STRING "\n"); printf("v" VERSION_STRING "\n");
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
case 'c': case 'c':
strncpy(config_path, optarg, sizeof(config_path)); strncpy(config_path, optarg, sizeof(config_path) - 1);
break; break;
} }
} }