Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
socket: workaround coverity warning about time_t handling
Coverity really wants to warn if a time_t is cast to 32 bits. We use time() here to get (some very bad) randomness. The loss of the upper bits is the least of the problems. Work around the coverity warning by also the higher bits. Error: Y2K38_SAFETY (CWE-197): [#def12] libnl-3.8.0/lib/socket.c:76: store_truncates_time_t: A "time_t" value is stored in an integer with too few bits to accommodate it. The expression "time(NULL)" is cast to "uint32_t". # 74| # 75| if (idx_state == 0) { # 76|-> uint32_t t = (uint32_t) time(NULL); # 77| # 78| /* from time to time (on average each 2^15 calls), the idx_state will Error: Y2K38_SAFETY (CWE-197): [#def13] libnl-3.8.0/lib/socket.c:193: store_truncates_time_t: A "time_t" value is stored in an integer with too few bits to accommodate it. The expression "time(NULL)" is cast to "unsigned int". # 191| sk->s_local.nl_family = AF_NETLINK; # 192| sk->s_peer.nl_family = AF_NETLINK; # 193|-> sk->s_seq_next = (unsigned int) time(NULL); # 194| sk->s_seq_expect = sk->s_seq_next; # 195|
- Loading branch information