Mercurial > hg > nginx
view src/mysql/ngx_mysql.h @ 5418:6961d52ebc49 stable-1.4
Core: fix misallocation at ngx_crypt_apr1 (ticket #412).
Found by using auth_basic.t from mdounin nginx-tests under valgrind.
==10470== Invalid write of size 1
==10470== at 0x43603D: ngx_crypt_to64 (ngx_crypt.c:168)
==10470== by 0x43648E: ngx_crypt (ngx_crypt.c:153)
==10470== by 0x489D8B: ngx_http_auth_basic_crypt_handler (ngx_http_auth_basic_module.c:297)
==10470== by 0x48A24A: ngx_http_auth_basic_handler (ngx_http_auth_basic_module.c:240)
==10470== by 0x44EAB9: ngx_http_core_access_phase (ngx_http_core_module.c:1121)
==10470== by 0x44A822: ngx_http_core_run_phases (ngx_http_core_module.c:895)
==10470== by 0x44A932: ngx_http_handler (ngx_http_core_module.c:878)
==10470== by 0x455EEF: ngx_http_process_request (ngx_http_request.c:1852)
==10470== by 0x456527: ngx_http_process_request_headers (ngx_http_request.c:1283)
==10470== by 0x456A91: ngx_http_process_request_line (ngx_http_request.c:964)
==10470== by 0x457097: ngx_http_wait_request_handler (ngx_http_request.c:486)
==10470== by 0x4411EE: ngx_epoll_process_events (ngx_epoll_module.c:691)
==10470== Address 0x5866fab is 0 bytes after a block of size 27 alloc'd
==10470== at 0x4A074CD: malloc (vg_replace_malloc.c:236)
==10470== by 0x43B251: ngx_alloc (ngx_alloc.c:22)
==10470== by 0x421B0D: ngx_malloc (ngx_palloc.c:119)
==10470== by 0x421B65: ngx_pnalloc (ngx_palloc.c:147)
==10470== by 0x436368: ngx_crypt (ngx_crypt.c:140)
==10470== by 0x489D8B: ngx_http_auth_basic_crypt_handler (ngx_http_auth_basic_module.c:297)
==10470== by 0x48A24A: ngx_http_auth_basic_handler (ngx_http_auth_basic_module.c:240)
==10470== by 0x44EAB9: ngx_http_core_access_phase (ngx_http_core_module.c:1121)
==10470== by 0x44A822: ngx_http_core_run_phases (ngx_http_core_module.c:895)
==10470== by 0x44A932: ngx_http_handler (ngx_http_core_module.c:878)
==10470== by 0x455EEF: ngx_http_process_request (ngx_http_request.c:1852)
==10470== by 0x456527: ngx_http_process_request_headers (ngx_http_request.c:1283)
==10470==
author | Markus Linnala <Markus.Linnala@cybercom.com> |
---|---|
date | Fri, 20 Sep 2013 17:57:21 +0300 |
parents | d620f497c50f |
children |
line wrap: on
line source
/* * Copyright (C) Igor Sysoev * Copyright (C) Nginx, Inc. */ #ifndef _NGX_MYSQL_H_INCLUDED_ #define _NGX_MYSQL_H_INCLUDED_ #include <ngx_config.h> #include <ngx_core.h> #include <ngx_event.h> #include <ngx_event_connect.h> typedef struct ngx_mysql_s ngx_mysql_t; typedef void (*ngx_mysql_handler_pt)(ngx_mysql_t *m); struct ngx_mysql_s { ngx_peer_connection_t peer; ngx_buf_t *buf; ngx_pool_t *pool; ngx_str_t *login; ngx_str_t *passwd; ngx_str_t *database; ngx_str_t query; ngx_uint_t pktn; ngx_mysql_handler_pt handler; void *data; ngx_int_t state; }; #define NGX_MYSQL_CMDPKT_LEN 5 #if (NGX_HAVE_LITTLE_ENDIAN && NGX_HAVE_NONALIGNED && 0) #define ngx_m16toh(n) (*(uint32_t *) n & 0x0000ffff) #define ngx_m24toh(n) (*(uint32_t *) n & 0x00ffffff) #define ngx_m32toh(n) *(uint32_t *) n #define ngx_htom16(n, m) *(uint16_t *) n = (uint16_t) ((m) & 0xffff) #define ngx_htom24(n, m) (n)[0] = (u_char) ((m) & 0xff); \ (n)[1] = (u_char) (((m) >> 8) & 0xff); \ (n)[2] = (u_char) (((m) >> 16) & 0xff) #define ngx_htom32(n, m) *(uint32_t *) (n) = (m) #else #define ngx_m16toh(n) (n[0] | n[1] << 8) #define ngx_m24toh(n) (n[0] | n[1] << 8 | n[2] << 16) #define ngx_m32toh(n) (n[0] | n[1] << 8 | n[2] << 16 | n[3] << 24) #define ngx_htom16(n, m) (n)[0] = (u_char) (m); (n)[1] = (u_char) ((m) >> 8) #define ngx_htom24(n, m) (n)[0] = (u_char) ((m) & 0xff); \ (n)[1] = (u_char) (((m) >> 8) & 0xff); \ (n)[2] = (u_char) (((m) >> 16) & 0xff) #define ngx_htom32(n, m) (n)[0] = (u_char) ((m) & 0xff); \ (n)[1] = (u_char) (((m) >> 8) & 0xff); \ (n)[2] = (u_char) (((m) >> 16) & 0xff); \ (n)[3] = (u_char) (((m) >> 24) & 0xff) #endif ngx_int_t ngx_mysql_connect(ngx_mysql_t *m); ngx_int_t ngx_mysql_query(ngx_mysql_t *m); #endif /* _NGX_MYSQL_H_INCLUDED_ */