CNFS offset problems

Russ Allbery rra at stanford.edu
Wed Jan 22 18:36:14 UTC 2003


bill davidsen <davidsen at tmr.com> writes:

> A 2GB article?!!! I thought I had problems with users complaining that
> they spent hours uploading a uuencoded CD as a single post and it was
> rejected, does someone really allow 2GB?

Think of it as future-proofing.  *heh*  Really, it's more that if I was
going to fix it, I wanted to get the fix completely correct.

> And why would it break? Since article.len is unsigned the LHS should be
> evaluated as unsigned, should it not? It's the RHS which is signed, I
> thought.

Yes, but you're adding a size_t to two small constants, which means that
the constants get promoted to size_t and then the arithmetic takes place
under unsigned rules at whatever size size_t is.  If it's 32 bits, this
means that overflow wraps (under C unsigned arithmetic rules), so an
article.len of 4GB - 1 (not 2GB, sorry) will end up making the LHS equal
to CNFS_BLOCKSIZE after overflow.

-- 
Russ Allbery (rra at stanford.edu)             <http://www.eyrie.org/~eagle/>

    Please send questions to the list rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.


More information about the inn-workers mailing list