pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/net/libfetch/files



Module Name:    pkgsrc
Committed By:   tnn
Date:           Thu Aug  6 14:02:38 UTC 2009

Modified Files:
        pkgsrc/net/libfetch/files: ftp.c

Log Message:
Fix strict aliasing issue which GCC 4.4 complained about.

While we know that "struct sockaddr_storage" has been engineered to alias
to all the sockaddr structs, the compiler does not know about this.
Thus, code like this may be unsafe to use:

struct sockaddr_storage ss;
struct sockaddr_in *sin = &ss;
sin->sin_port = 0; /* dereferencing here breaks ISO C aliasing rules */

A workaround is to wrap the struct in a union, e.g:
union anonymous {
  struct sockaddr_storage ss;
  struct sockaddr_in sin;
} u;
u.sin.sin_port = 0;
--
Approved by: joerg


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 pkgsrc/net/libfetch/files/ftp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Home | Main Index | Thread Index | Old Index