@@ -348,6 +348,7 @@ int fpm_sockets_init_main() /* {{{ */
348
348
unsigned i , lq_len ;
349
349
struct fpm_worker_pool_s * wp ;
350
350
char sockname [32 ];
351
+ char sockpath [256 ];
351
352
char * inherited ;
352
353
struct listening_socket_s * ls ;
353
354
@@ -363,7 +364,9 @@ int fpm_sockets_init_main() /* {{{ */
363
364
sprintf (sockname , "FPM_SOCKETS_%d" , i );
364
365
}
365
366
inherited = getenv (sockname );
366
- if (!inherited ) break ;
367
+ if (!inherited ) {
368
+ break ;
369
+ }
367
370
368
371
while (inherited && * inherited ) {
369
372
char * comma = strchr (inherited , ',' );
@@ -376,11 +379,17 @@ int fpm_sockets_init_main() /* {{{ */
376
379
377
380
eq = strchr (inherited , '=' );
378
381
if (eq ) {
379
- * eq = '\0' ;
382
+ int sockpath_len = eq - inherited ;
383
+ if (sockpath_len > 255 ) {
384
+ /* this should never happen as UDS limit is lower */
385
+ sockpath_len = 255 ;
386
+ }
387
+ memcpy (sockpath , inherited , sockpath_len );
388
+ sockpath [sockpath_len ] = '\0' ;
380
389
fd_no = atoi (eq + 1 );
381
- type = fpm_sockets_domain_from_address (inherited );
382
- zlog (ZLOG_NOTICE , "using inherited socket fd=%d, \"%s\"" , fd_no , inherited );
383
- fpm_sockets_hash_op (fd_no , 0 , inherited , type , FPM_STORE_SOCKET );
390
+ type = fpm_sockets_domain_from_address (sockpath );
391
+ zlog (ZLOG_NOTICE , "using inherited socket fd=%d, \"%s\"" , fd_no , sockpath );
392
+ fpm_sockets_hash_op (fd_no , 0 , sockpath , type , FPM_STORE_SOCKET );
384
393
}
385
394
386
395
if (comma ) {
0 commit comments