This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH,HURD] sendto: do not crash when addr is NULL
- From: Roland McGrath <roland at hack dot frob dot com>
- To: Pino Toscano <toscano dot pino at tiscali dot it>
- Cc: libc-alpha at sourceware dot org, bug-hurd at gnu dot org
- Date: Mon, 21 May 2012 13:00:03 -0700 (PDT)
- Subject: Re: [PATCH,HURD] sendto: do not crash when addr is NULL
- References: <201205202258.36132.toscano.pino@tiscali.it>
Put the name of a local variable in all caps when mentioning it in the log
entry or comments.
Initializing ERR at the top is confusingly subtle.
Instead, you make the code that actually cares look like:
if (addr == NULL || addr->sun_family == AF_LOCAL)
err = 0;
else
err = __socket_create_address (...);
if (! err)
...
It looks like the existing code also has a leak of APORT in the case where
HURD_DPORT_USE fails (i.e. invalid fd). So you should reorganize in some
way that fixes that too.
It might be simplest just to move the creation of the address port (both
the AF_LOCAL case and the default case) into a subroutine and just call
that inside HURD_DPORT_USE. It means that the descriptor structure and
port are kept alive around the AF_LOCAL case's calls, but that seems OK.
Thanks,
Roland