]> granicus.if.org Git - php/commitdiff
68440: ensure backwards compatibility with FPM_SOCKETS var; fix sockname size
authorJacob Hipps <jacob@ycnrg.org>
Mon, 26 Feb 2018 15:25:24 +0000 (10:25 -0500)
committerJakub Zelenka <bukka@php.net>
Fri, 30 Mar 2018 16:20:19 +0000 (17:20 +0100)
sapi/fpm/fpm/fpm_sockets.c

index dc7a8abd7283ac373af89fc4d478e3bd7c950f46..c1049b577ab35e1d4f4aaa57783aff270e1b8399 100644 (file)
@@ -47,7 +47,7 @@ static void fpm_sockets_cleanup(int which, void *arg) /* {{{ */
        unsigned socket_set_count = 0;
        unsigned socket_set[FPM_ENV_SOCKET_SET_MAX];
        unsigned socket_set_buf = 0;
-       char envname[16];
+       char envname[32];
        char *env_value = 0;
        int p = 0;
        struct listening_socket_s *ls = sockets_list.data;
@@ -83,8 +83,12 @@ static void fpm_sockets_cleanup(int which, void *arg) /* {{{ */
        }
 
        if (env_value) {
-               for(i = 0; i < socket_set_count; i++) {
-                       sprintf(envname, "FPM_SOCKETS_%d", i);
+               for (i = 0; i < socket_set_count; i++) {
+                       if (!i) {
+                               strcpy(envname, "FPM_SOCKETS");
+                       } else {
+                               sprintf(envname, "FPM_SOCKETS_%d", i);
+                       }
                        setenv(envname, env_value + socket_set[i], 1);
                }
                free(env_value);
@@ -343,7 +347,7 @@ int fpm_sockets_init_main() /* {{{ */
 {
        unsigned i, lq_len;
        struct fpm_worker_pool_s *wp;
-       char sockname[16];
+       char sockname[32];
        char *inherited;
        struct listening_socket_s *ls;
 
@@ -353,7 +357,11 @@ int fpm_sockets_init_main() /* {{{ */
 
        /* import inherited sockets */
        for (i = 0; i < FPM_ENV_SOCKET_SET_MAX; i++) {
-               sprintf(sockname, "FPM_SOCKETS_%d", i);
+               if (!i) {
+                       strcpy(sockname, "FPM_SOCKETS");
+               } else {
+                       sprintf(sockname, "FPM_SOCKETS_%d", i);
+               }
                inherited = getenv(sockname);
                if (!inherited) break;