Created attachment 153941 [details] Fix According to coverity 1193663, the following check always yields a false result: 405 if (st.st_size > SIZE_T_MAX) { 406 _close(fd); 407 SAVEFAIL(name, lang, EFBIG); 408 NLRETERR(EFBIG); 409 } _____ result_independent_of_operands: st.st_size > 18446744073709551615ULL is always false regardless of the values of its operands. This occurs as the logical operand of if. We can workaround this by excluding also SIZE_T_MAX but we should also exclude negative values since that would indicate an overflow.
Add Gabor since he is the author of the code.
Forgot to mention the code in question is in lib/libc/nls/msgcat.c
This Coverity warning is sort of dubious. It's true on our 64-bit architectures, where sizeof(size_t) == sizeof(off_t); but it's not true on our 32-bit architectures, where size_t is half as big. I think we should just ignore the CID in Coverity and move on. It would be a pretty major OS bug for st_size to ever be negative, so I don't like the proposed patch. If you want to add a KASSERT to sys_stat or kern_stat that st_size is >= 0, I would support that instead.
Hmm ... yes, this is really old ... I think we could do an #ifdef trickery to work around the coverity report but it is probably not worth it. Thanks for looking.