in reply to Re: [OT] LLP64 .v. LP64 portability
in thread [OT] LLP64 .v. LP64 portability
I fixed those problems in substr for 5.12.0
Well done. But--this isn't critism, just a need for understanding--those fixes look very complex in places.
For example:
- else { - pos += curlen; - if (num_args < 3) - rem = curlen; - else if (len >= 0) { - rem = pos+len; - if (rem > (I32)curlen) - rem = curlen;
becomes
+ if (pos1_is_uv || pos1_iv > 0) { + if ((UV)pos1_iv > curlen) + goto BOUND_FAIL; + } + + if (num_args > 2) { + if (!len_is_uv && len_iv < 0) { + pos2_iv = curlen + len_iv; + if (curlen) + pos2_is_uv = curlen-1 > ~(UV)len_iv; + else + pos2_is_uv = 0; + } else { /* len_iv >= 0 */ + if (!pos1_is_uv && pos1_iv < 0) { + pos2_iv = pos1_iv + len_iv; + pos2_is_uv = (UV)len_iv > (UV)IV_MAX; + } else { + if ((UV)len_iv > curlen-(UV)pos1_iv) + pos2_iv = curlen; + else + pos2_iv = pos1_iv+len_iv; + pos2_is_uv = 1; + }
Is all of that manual tracking whether a integer is signed or unsigned necessary?
If so, life just got a whole lot tougher for source-divers. That's really nasty!
but some remain elsewhere.
I'm currently looking at 1988 (1302 uniq), "possible loss of data" warnings spread across 73 source files in the 5.12.0 release.
Don't you just wish that C compilers would list the identifier of offending variables!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: [OT] LLP64 .v. LP64 portability
by syphilis (Archbishop) on Apr 21, 2010 at 09:10 UTC | |
by BrowserUk (Patriarch) on Apr 21, 2010 at 10:39 UTC | |
by ikegami (Patriarch) on Apr 22, 2010 at 02:44 UTC | |
by BrowserUk (Patriarch) on Apr 22, 2010 at 03:19 UTC | |
by ikegami (Patriarch) on Apr 22, 2010 at 05:47 UTC | |
| |
|
Re^3: [OT] LLP64 .v. LP64 portability
by ikegami (Patriarch) on Apr 21, 2010 at 14:38 UTC | |
by BrowserUk (Patriarch) on Apr 21, 2010 at 19:39 UTC | |
by ikegami (Patriarch) on Apr 21, 2010 at 20:11 UTC | |
by ikegami (Patriarch) on Apr 21, 2010 at 20:19 UTC | |
by BrowserUk (Patriarch) on Apr 21, 2010 at 22:02 UTC |