vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I just saw this while compiling -current: ===> libexec/identd cc -O2 -pipe -Wall -c /usr/src/libexec/identd/identd.c cc -O2 -pipe -Wall -c /usr/src/libexec/identd/openbsd.c /usr/src/libexec/identd/openbsd.c: In function `k_getuid6': /usr/src/libexec/identd/openbsd.c:89: warning: comparison is always false due to limited range of data type /usr/src/libexec/identd/openbsd.c:92: warning: comparison is always false due to limited range of data type The lines in question are: 89: if (faddr->sin6_len > sizeof(tir.faddr)) return -1; memcpy(fin, faddr, faddr->sin6_len); 92: if (laddr->sin6_len > sizeof(tir.laddr)) return -1; memcpy(lin, laddr, laddr->sin6_len); Both faddr and laddr are of type struct sockaddr_in6. (defined in netinet6/in6.h), and the sin6_len member is a u_int8_t: struct sockaddr_in6 { u_int8_t sin6_len; /* length of this struct(sa_family_t)*/ tir.faddr and tir.laddr are of type struct sockaddr_storage, defined in sys/socket.h: struct sockaddr_storage { u_int8_t ss_len; /* total length */ sa_family_t ss_family; /* address family */ unsigned char __ss_pad1[6]; /* align to quad */ u_int64_t __ss_pad2; /* force alignment for stupid compilers */ unsigned char __ss_pad3[240]; /* pad to a total of 256 bytes */ }; Since sockaddr_storage is padded to 256 bytes there is indeed no way that [fl]addr->sin6_len can be larger than sizeof(struct sockaddr_storage). So I'm wondering whether the checks in lines 89 and 92 of libexec/identd/openbsd.c are really bogus or if there is a reason for them, like explicitely guarding the code against future type size changes? If so, is there a way to get rid of the warning but still retain the safety net? This has been in the tree for 7 years now so I doubt no one has seen this warning before... Just curious, thanks, -- stefan http://stsp.name PGP Key: 0xF59D25F0 [demime 1.01d removed an attachment of type application/pgp-signature] |
| Thread Tools | |
| Display Modes | |
|
|