Bug 1825 - ipv64_normalise_mapped()'s memset should use a4, not addr, for clarity
Summary: ipv64_normalise_mapped()'s memset should use a4, not addr, for clarity
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Miscellaneous (show other bugs)
Version: 5.6p1
Hardware: All All
: P2 trivial
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_5_7
  Show dependency treegraph
 
Reported: 2010-09-23 12:04 AEST by foo
Modified: 2011-01-24 12:34 AEDT (History)
1 user (show)

See Also:


Attachments
/home/djm/canohost-warnfix.diff (532 bytes, patch)
2010-10-12 13:24 AEDT, Damien Miller
dtucker: ok+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description foo 2010-09-23 12:04:13 AEST
The current code in "canohost.c" looks like this:

void
ipv64_normalise_mapped(struct sockaddr_storage *addr, socklen_t *len)
{
	struct sockaddr_in6 *a6 = (struct sockaddr_in6 *)addr;
	struct sockaddr_in *a4 = (struct sockaddr_in *)addr;
...
	memset(addr, 0, sizeof(*a4));


That last line has the correct behavior, but it would help with static analysis and compiler diagnostics if it were written as:
	memset(a4, 0, sizeof(*a4));

A compiler here unnamed gives a warning on the unmodified line, because it sees that *addr is not the same size as *a4 and therefore the memset() might be setting the "wrong" number of bytes.  If we change the code to use a4 consistently when referring to an IPv4 sockaddr, the compiler is happier, and incidentally the code's correctness is more obvious, too.
Comment 1 Damien Miller 2010-10-12 13:24:18 AEDT
Created attachment 1933 [details]
/home/djm/canohost-warnfix.diff
Comment 2 Damien Miller 2010-10-12 13:29:07 AEDT
Patch applied - thanks.
Comment 3 Damien Miller 2011-01-24 12:34:07 AEDT
Move resolved bugs to CLOSED after 5.7 release