[stunnel-users] [PATCH] Fix undefined aliasing in libwrap.c

Miloslav Trmac mitr at redhat.com
Sat May 2 22:57:32 CEST 2009


----- "Michal Trojnara" <Michal.Trojnara at mobi-com.net> wrote:

> Miloslav Trmac wrote:
> > The attached patch changes the code not to access a part of a  
> > char[...] array using an int *, which is undefined in ISO C.
> 
> Casting pointers is undefined?
No (as long as alignment restrictions are not violated), but accessing an object of one type via a pointer of other type is undefined for most combinations of the types.  

> Where did you find it?
In the C standard :)  Besides, GCC warns quite loudly.

http://mail-index.netbsd.org/tech-kern/2003/08/11/0001.html is a good description of the issue.
    Mirek



More information about the stunnel-users mailing list