Opened 8 years ago

Closed 8 years ago

#898 closed defect (fixed)

nginx_version is not casted to unsinged integer.

Reported by: ttkzw@… Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.9.x
Keywords: Cc:
uname -a: Linux centos7-1 3.10.0-327.4.5.el7.x86_64 #1 SMP Mon Jan 25 22:07:14 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.9.11
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_slice_module --with-threads --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --add-dynamic-module=/home/taki/src/ngx_http_hello_world

Description

Because nginx_version is not casted to unsinged integer,
nginx does not output the correct version.

nginx: [emerg] module "/usr/local/nginx/modules/ngx_http_hello_world_module.so" version 1009012 instead of 140166258713971 in /usr/local/nginx/conf/nginx.conf:13

The following patch fixes the issue.

diff -r 70e6e1f12dee src/core/ngx_module.c
--- a/src/core/ngx_module.c	Thu Feb 11 14:20:26 2016 +0300
+++ b/src/core/ngx_module.c	Thu Feb 11 22:54:36 2016 +0900
@@ -168,10 +168,10 @@
         return NGX_ERROR;
     }
 
-    if (module->version != nginx_version) {
+    if (module->version != (ngx_uint_t) nginx_version) {
         ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                            "module \"%V\" version %ui instead of %ui",
-                           file, module->version, nginx_version);
+                           file, module->version, (ngx_uint_t) nginx_version);
         return NGX_ERROR;
     }
 

Change History (3)

comment:1 by Valentin V. Bartenev, 8 years ago

IMO, it's better to adjust specifier instead:

diff -r 73e7f0a798f5 src/core/ngx_module.c
--- a/src/core/ngx_module.c     Thu Feb 11 15:35:36 2016 +0300
+++ b/src/core/ngx_module.c     Thu Feb 11 17:38:44 2016 +0300
@@ -170,7 +170,7 @@ ngx_add_module(ngx_conf_t *cf, ngx_str_t
 
     if (module->version != nginx_version) {
         ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
-                           "module \"%V\" version %ui instead of %ui",
+                           "module \"%V\" version %ui instead of %d",
                            file, module->version, nginx_version);
         return NGX_ERROR;
     }

comment:2 by Ruslan Ermilov <ru@…>, 8 years ago

In 6394:5fe617f38222/nginx:

Dynamic modules: fixed a version mismatch message (ticket #898).

Based on a patch by Takashi Takizawa.

comment:3 by Ruslan Ermilov, 8 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.