Opened 8 years ago

Closed 8 years ago

#1072 closed defect (fixed)

Overflow in ngx_atosz with Visual Studio 2013 in 64bit system

Reported by: ansarhun@… Owned by:
Priority: minor Milestone:
Component: other Version: 1.8.x
Keywords: Cc:
uname -a:
nginx -V: nginx version: nginx/1.8.1
built with OpenSSL 1.0.2a 19 Mar 2015
TLS SNI support enabled
configure arguments:CMakeLists.txt

Description

When I was trying to set Content-Length header from lua, I got an error that setting the header failed.

The error occured in

ngx_http_set_content_length_header

, when it tried to parse the data with

ngx_atosz

.

The ssize_t is defined as int which is 32bit in visual studio.
When setting the NGX_MAX_SIZE_T_VALUE value to a ssize_t variable it overflows, and checks fail with cutoff:

if (value >= cutoff && (value > cutoff || *line - '0' > cutlim)) {

Changing the define in ngx_win32_config.h to

__int64

solves the problem.

#ifndef __MINGW64_VERSION_MAJOR
typedef __int64                 ssize_t;
#endif

Change History (1)

comment:1 by Maxim Dounin, 8 years ago

Resolution: fixed
Status: newclosed

Basic support of 64-bit compilation with MSVC was added in e4590dfd97ff.

Note: See TracTickets for help on using tickets.