Trouble if mapping hostname with multiple address

Bug #691871 reported by Mahyuddin Susanto on 2010-12-18
This bug affects 1 person
Affects Status Importance Assigned to Milestone
nginx (Ubuntu)
Mahyuddin Susanto

Bug Description

Binary package hint: nginx

As describe at:
In ngx_inet.c, there is a code piece of function
"ngx_inet_resolve_host". If I set u->one_addr to 1, but unfortunately
this hostname map to multiple IP addresses, such as
[code] myhost myhost
in /etc/hosts.

h->h_addr_list will be 2 entries before NULL. Each of them will be
converted to human readable format and assigned to u->addrs[ i ].
However, when one_addr is set, [b]u->addrs will be allocated ONLY ONE
ngx_addr_t mem.[/b] In this way, a mem crash is inevitable.

I set one_addr to 1 because I'm writing a custom module and want to
connect another server. Sadly the server is also running on the local
host with multiple IP in /etc/hosts. I want to connect the first IP
match that host name ( because that server require a
non-lookback IP. I thought "one_addr" means "fetch the first found IP".
But seems I was wrong.

Besides this, I insist alloc mem with "i", but loop will h->h_addr_list
is very dangerous. Report an error is more suitable rather than leave a
time bomb.

Affected version: all versions!!!

$ apt-cache policy nginx
  Installed: 0.7.65-1ubuntu2
  Candidate: 0.7.65-1ubuntu2
  Version table:
 *** 0.7.65-1ubuntu2 0
        500 lucid/universe Packages
        100 /var/lib/dpkg/status

$ nginx -V
nginx version: nginx/0.7.65
TLS SNI support enabled
configure arguments: --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/ --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-http_stub_status_module --with-http_flv_module --with-http_ssl_module --with-http_dav_module --with-http_gzip_static_module --with-http_realip_module --with-mail --with-mail_ssl_module --with-ipv6 --add-module=/build/buildd/nginx-0.7.65/modules/nginx-upstream-fair

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 10.04.1 LTS
Release: 10.04
Codename: lucid

Mahyuddin Susanto (udienz) wrote :
Changed in nginx (Ubuntu):
assignee: nobody → Mahyuddin Susanto (udienz)
summary: - Trouble if mapping hostname mapping with multiple address
+ Trouble if mapping hostname with multiple address
tags: added: patch
description: updated
Daniel Hahler (blueyed) wrote :

Just for reference, the proposed patch is taken from the mailing list, at

Mahyuddin Susanto (udienz) wrote :

yes already writing at patch file

This is being dealt with upstream. It will be taken care of before Natty release. Please see bug 692087 and note the comment requesting a wait on the sync until 0.8.54-1 where the source is already patched.

Mahyuddin Susanto (udienz) wrote :

This is SRU updates, not natty

Mahyuddin Susanto (udienz) wrote :

This is SRU updates for lucid, not for natty

Changed in nginx (Ubuntu):
assignee: Mahyuddin Susanto (udienz) → nobody
Changed in nginx (Ubuntu):
status: New → In Progress
tags: added: regression-proposed
Changed in nginx (Ubuntu):
assignee: nobody → Mahyuddin Susanto (udienz)
tags: removed: regression-proposed

This has been fixed in Debian. I don't see where this bug should be SRU'ed. However, the new version of Nginx could be proposed for backports.

Changed in nginx (Ubuntu):
status: In Progress → Fix Committed

Marking as Fix Released as this has been resolved in Debian and the package has since been sync'ed to Ubuntu.

Changed in nginx (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers