[PATCH] fix crash with ngx_setproctitle
Markus Linnala
Markus.Linnala at cybercom.com
Sun Aug 17 20:24:00 UTC 2014
Test ngx_init_setproctitle return value to prevent crash at ngx_setproctitle.
Added modifications not to break environments without setproctitle.
Fix from Maxim Dounin.
diff -r 79553cb77747 -r 69fdb8f8270e 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;
diff -r 79553cb77747 -r 69fdb8f8270e src/os/unix/ngx_setproctitle.h
--- a/src/os/unix/ngx_setproctitle.h Fri Aug 15 14:09:29 2014 +0400
+++ b/src/os/unix/ngx_setproctitle.h Sun Aug 17 21:01:53 2014 +0300
@@ -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 @@
#else
-#define ngx_init_setproctitle(log)
+#define ngx_init_setproctitle(log) NGX_OK
#define ngx_setproctitle(title)
#endif /* OSes */
More information about the nginx-devel
mailing list