]> git.kaiwu.me - nginx.git/commitdiff
Added ngx_init_setproctitle() return code check.
authorMaxim Dounin <mdounin@mdounin.ru>
Mon, 8 Sep 2014 17:36:09 +0000 (21:36 +0400)
committerMaxim Dounin <mdounin@mdounin.ru>
Mon, 8 Sep 2014 17:36:09 +0000 (21:36 +0400)
The ngx_init_setproctitle() function, as used on systems without
setproctitle(3), may fail due to memory allocation errors, and
therefore its return code needs to be checked.

Reported by Markus Linnala.

src/os/unix/ngx_posix_init.c
src/os/unix/ngx_setproctitle.h

index 9a4de022d6d949a57e508693af95093d34225bd1..bf3a310aa3b63f26a9b69db57db9c7db66358cd1 100644 (file)
@@ -40,7 +40,9 @@ ngx_os_init(ngx_log_t *log)
     }
 #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;
index 2323408c46ee615872bd9dc09ee56f53dc3557f0..c3636628bb745680d7b988f709c14b55e00256d9 100644 (file)
@@ -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 */