[PATCH] Limit req: pointer init order issue
Maxim Dounin
mdounin at mdounin.ru
Mon May 20 22:28:33 UTC 2013
Hello!
On Mon, May 20, 2013 at 11:55:48PM +0200, Filipe Da Silva wrote:
> Hello,
>
> It's a tiny issue as only the next test code about 'shm' is broken.
>
> That's my last patch for the moment.
>
> Regards.
> Filipe DA SILVA
> # HG changeset patch
> # User F. da Silva<fdasilvayy at gmail.com>
> # Date 1368198460 -7200
> # Fri May 10 17:07:40 2013 +0200
> # Node ID 44310812509300443b296e4ff0292e0934305a55
> # Parent 8abca47e7ca0537000bbbd307eefdd033a9971e7
> Limit req: pointer init order issue.
>
> diff -r 8abca47e7ca0 -r 443108125093 src/http/modules/ngx_http_limit_req_module.c
> --- a/src/http/modules/ngx_http_limit_req_module.c Fri May 10 16:53:45 2013 +0200
> +++ b/src/http/modules/ngx_http_limit_req_module.c Fri May 10 17:07:40 2013 +0200
> @@ -936,9 +936,7 @@
> return NGX_CONF_ERROR;
> }
>
> - limits = lrcf->limits.elts;
> -
> - if (limits == NULL) {
> + if (lrcf->limits.elts == NULL) {
> if (ngx_array_init(&lrcf->limits, cf->pool, 1,
> sizeof(ngx_http_limit_req_limit_t))
> != NGX_OK)
> @@ -947,6 +945,8 @@
> }
> }
>
> + limits = lrcf->limits.elts;
> +
> for (i = 0; i < lrcf->limits.nelts; i++) {
> if (shm_zone == limits[i].shm_zone) {
> return "is duplicate";
There is no problem here: if lrcf->limits.elts == NULL (aka
limits == NULL), then lrcf->limits.nelts == 0 and the limits
pointer is never dereferenced. The patch is not needed.
--
Maxim Dounin
http://nginx.org/en/donation.html
More information about the nginx-devel
mailing list