Welcome! Log In Create A New Profile

Advanced

Heap corruption in win32 compiled by VC

July 13, 2011 01:36AM
I checkout the newest code from svn and compiled it by vc, but an exception occurred. So I modified cl option to -MTd compiled again.
The windbg shows that CheckBytes function return false when calling ngx_free() at ngx_shmem.c:43.

I think that ngx_sprintf must put more than name's alloc size bytes into name, So I use ngx_snprintf to replace ngx_sprintf. The problem disappeared. Is it useful?

name = ngx_alloc(shm->name.len + 2 + sizeof(NGX_INT32_LEN), shm->log);
if (name == NULL) {
return NGX_ERROR;
}

- (void) ngx_sprintf(name, "%V_%s%Z", &shm->name, ngx_unique);
+ (void) ngx_snprintf(name, shm->name.len + 2 + sizeof(NGX_INT32_LEN),
+ "%V_%s%Z", &shm->name, ngx_unique);
Subject Author Posted

Heap corruption in win32 compiled by VC

bigplum July 13, 2011 01:36AM

Re: Heap corruption in win32 compiled by VC

Maxim Dounin July 13, 2011 07:00AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 241
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready