Welcome! Log In Create A New Profile

Advanced

Re: Format string bug

Maxim Dounin
June 10, 2021 12:52PM
Hello!

On Thu, Jun 10, 2021 at 11:07:39AM -0400, Jan Kasiak wrote:

> I think there is a bug in one of the format strings.
>
> diff --git a/src/os/win32/ngx_win32_init.c b/src/os/win32/ngx_win32_init.c
> index 3249fb29..11941f62 100644
> --- a/src/os/win32/ngx_win32_init.c
> +++ b/src/os/win32/ngx_win32_init.c
> @@ -305,7 +305,7 @@ ngx_os_status(ngx_log_t *log)
> /* Win9x build */
>
> ngx_log_error(NGX_LOG_INFO, log, 0,
> - "OS: %u build:%ud.%ud.%ud, \"%s\"",
> + "OS: %ud build:%ud.%ud.%ud, \"%s\"",
> ngx_win32_version,
> osvi.dwBuildNumber >> 24,
> (osvi.dwBuildNumber >> 16) & 0xff,

Yes, thanks.

Further, the "%ud" used elsewhere for ngx_win32_version is also incorrect,
given the ngx_uint_t type: it should be %ui instead.

The following patch fixes both issues:

# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1623342077 -10800
# Thu Jun 10 19:21:17 2021 +0300
# Node ID f7120b838d9c7647a711e53166a6f0f2522b35da
# Parent 5f765427c17ac8cf753967387562201cf4f78dc4
Fixed format strings for ngx_win32_version.

diff --git a/src/os/win32/ngx_win32_init.c b/src/os/win32/ngx_win32_init.c
--- a/src/os/win32/ngx_win32_init.c
+++ b/src/os/win32/ngx_win32_init.c
@@ -295,7 +295,7 @@ ngx_os_status(ngx_log_t *log)
osviex_stub = (ngx_osviex_stub_t *) &osvi.wServicePackMinor;

ngx_log_error(NGX_LOG_INFO, log, 0,
- "OS: %ud build:%ud, \"%s\", suite:%Xd, type:%ud",
+ "OS: %ui build:%ud, \"%s\", suite:%Xd, type:%ud",
ngx_win32_version, osvi.dwBuildNumber, osvi.szCSDVersion,
osviex_stub->wSuiteMask, osviex_stub->wProductType);

@@ -305,7 +305,7 @@ ngx_os_status(ngx_log_t *log)
/* Win9x build */

ngx_log_error(NGX_LOG_INFO, log, 0,
- "OS: %u build:%ud.%ud.%ud, \"%s\"",
+ "OS: %ui build:%ud.%ud.%ud, \"%s\"",
ngx_win32_version,
osvi.dwBuildNumber >> 24,
(osvi.dwBuildNumber >> 16) & 0xff,
@@ -321,7 +321,7 @@ ngx_os_status(ngx_log_t *log)
* and we do not support VER_PLATFORM_WIN32s at all
*/

- ngx_log_error(NGX_LOG_INFO, log, 0, "OS: %ud build:%ud, \"%s\"",
+ ngx_log_error(NGX_LOG_INFO, log, 0, "OS: %ui build:%ud, \"%s\"",
ngx_win32_version, osvi.dwBuildNumber,
osvi.szCSDVersion);
}



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

Format string bug

Jan Kasiak 103 June 10, 2021 11:10AM

Re: Format string bug

Maxim Dounin 48 June 10, 2021 12:52PM



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

Online Users

Guests: 85
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready