Welcome! Log In Create A New Profile

Advanced

Re: [PATCH 1 of 1] fix crash with ngx_setproctitle

Maxim Dounin
August 17, 2014 03:06PM
Hello!

On Sun, Aug 17, 2014 at 09:23:04PM +0300, Markus Linnala wrote:

> # HG changeset patch
> # User Markus Linnala <Markus.Linnala@cybercom.com>
> # Date 1408298513 -10800
> # Sun Aug 17 21:01:53 2014 +0300
> # Node ID 5524fc592881550bc5ed108993af148ebd09fa22
> # Parent 79553cb7774753f9c40a6fa6744b0e0611e41908
> fix crash with ngx_setproctitle
>
> Test ngx_init_setproctitle return value to prevent crash at ngx_setproctitle.
>
> diff -r 79553cb77747 -r 5524fc592881 src/os/unix/ngx_posix_init.c
> --- a/src/os/unix/ngx_posix_init.c Fri Aug 15 14:09:29 2014 +0400
> +++ b/src/os/unix/ngx_posix_init.c Sun Aug 17 21:01:53 2014 +0300
> @@ -40,7 +40,9 @@
> }
> #endif
>
> - ngx_init_setproctitle(log);
> + if (ngx_init_setproctitle(log) != NGX_OK) {
> + return NGX_ERROR;
> + }
>
> ngx_pagesize = getpagesize();
> ngx_cacheline_size = NGX_CPU_CACHE_LINE;

This is at least incomplete, it will only work for platforms where
ngx_init_setproctitle() actually does something. It break things
for platforms with setproctitle() and platforms where
setproctitle() can't be emulated.

At least something like this is needed:

--- a/src/os/unix/ngx_setproctitle.h
+++ b/src/os/unix/ngx_setproctitle.h
@@ -13,7 +13,7 @@

/* FreeBSD, NetBSD, OpenBSD */

-#define ngx_init_setproctitle(log)
+#define ngx_init_setproctitle(log) NGX_OK
#define ngx_setproctitle(title) setproctitle("%s", title)


@@ -39,7 +39,7 @@ void ngx_setproctitle(char *title);

#else

-#define ngx_init_setproctitle(log)
+#define ngx_init_setproctitle(log) NGX_OK
#define ngx_setproctitle(title)

#endif /* OSes */


--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 0 of 1] crash at src/os/unix/ngx_setproctitle.c:128

Markus Linnala 595 August 17, 2014 02:26PM

[PATCH 1 of 1] fix crash with ngx_setproctitle

Markus Linnala 273 August 17, 2014 02:26PM

Re: [PATCH 1 of 1] fix crash with ngx_setproctitle

Maxim Dounin 328 August 17, 2014 03:06PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 210
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready