Be more clear about what 108 means here towards the Unix socket
authorwwp <wwp@free.fr>
Tue, 10 Jan 2017 14:58:05 +0000 (15:58 +0100)
committerwwp <wwp@free.fr>
Tue, 10 Jan 2017 14:58:05 +0000 (15:58 +0100)
path value lenght: rely on UNIX_PATH_MAX and fallback to its common
value '108' in not defined in un.h (caution, on other systems, it could
be 104, etc. down to 92).

src/plugins/clamd/libclamd/clamd-plugin.c

index 1f05c2ccc93f8b0cbf37acc1c6b7c7137246a304..a3052296b0102bee7798e82c15d0f435f45e95e6 100644 (file)
@@ -301,9 +301,14 @@ static int create_socket() {
                        }
                        debug_print("socket file (create): %d\n", new_sock);
                        addr_u.sun_family = AF_UNIX;
-                       if (strlen(Socket->socket.path) > 108) {
-                               g_error("socket path longer than 108-char: %s", Socket->socket.path);
+#ifndef UNIX_PATH_MAX
+#define UNIX_PATH_MAX 108
+#endif
+                       if (strlen(Socket->socket.path) > UNIX_PATH_MAX) {
+                               g_error("socket path longer than %d-char: %s",
+                                       UNIX_PATH_MAX, Socket->socket.path);
                                new_sock = -2;
+#undef UNIX_PATH_MAX
                        } else {
                                memcpy(addr_u.sun_path, Socket->socket.path, 
                                                strlen(Socket->socket.path));