diff options
Diffstat (limited to 'acccre-server.c')
-rw-r--r-- | acccre-server.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/acccre-server.c b/acccre-server.c index 310317a..a3c1896 100644 --- a/acccre-server.c +++ b/acccre-server.c @@ -85,13 +85,13 @@ int main (int argc, char *argv[]) { DEFAULT_PATH /* sun_path */ }; if (argc > 1) { - /* Taken from https://pubs.opengroup.org/onlinepubs/9799919799/ */ - if (sizeof(argv[1]) >= sizeof(((struct sockaddr_un *)0)->sun_path)) { - strcpy(sun.sun_path, argv[1]); + size_t sun_path_length = strlen(argv[1]); + if (sun_path_length >= MAX_SUN_PATH) { + fprintf(stderr, "Size of path to the socket (%zu) is greater than, or equal to the maximum size (%zu).\n", sun_path_length, MAX_SUN_PATH); + exit(EXIT_FAILURE); } else { - fprintf(stderr, "Path to the socket is longer than %zu.\n", sizeof(((struct sockaddr_un *)0)->sun_path)); - exit(EXIT_FAILURE); + strcpy(sun.sun_path, argv[1]); } } |