Issue9647
Created on 2010-08-19 18:44 by baikie, last changed 2010-10-02 21:25 by baikie.
| Messages (3) | |||
|---|---|---|---|
| msg114396 - (view) | Author: David Watson (baikie) | Date: 2010-08-19 18:44 | |
This came up in relation to issue #9579; there is some discussion of it there. Basically, if os.confstr() has to call confstr() twice because the buffer wasn't big enough the first time, the existing code assumes the string is the same length that the OS reported in the first call instead of using the length from the second call and resizing the buffer if necessary. This means the returned value will be truncated or contain trailing garbage if the string changed its length betweeen calls. I don't know of an actual environment where configuration strings can change at runtime, but it's not forbidden by POSIX as far as I can see (the strings are described as "variables", after all, and sysconf() values such as CHILD_MAX can change at runtime). Implementations can also provide additional confstr() variables not specified by POSIX. The patch confstr-long-result.diff at issue #9579 would fix this (for 3.x), but Victor Stinner has expressed concern that a buggy confstr() could create a near-infinite loop with that patch applied. |
|||
| msg117633 - (view) | Author: STINNER Victor (haypo) * ![]() |
Date: 2010-09-29 17:32 | |
If I understood correctly, you don't want the value to be truncated if the variable grows between the two calls to confstr(). Which behaviour would you expect? A Python exception? > but Victor Stinner has expressed concern that a buggy > confstr() could create a near-infinite loop with that patch > applied Yes, I think that two calls to confstr() should be enough. |
|||
| msg117898 - (view) | Author: David Watson (baikie) | Date: 2010-10-02 21:25 | |
> If I understood correctly, you don't want the value to be truncated if the variable grows between the two calls to confstr(). Which behaviour would you expect? A Python exception? A return size larger than the buffer is *supposed* to indicate that the current value is larger than the supplied buffer, so I would just expect it to reallocate the buffer, call confstr() again and return the new value, unless it was known that such a situation indicated an actual problem. In other words, I would not expect it to do anything special. I didn't write the original patch the way I did in order to fix this (potential) bug - it just seemed like the most natural way to write the code. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2010-10-02 21:25:45 | baikie | set | messages: + msg117898 |
| 2010-09-29 17:32:38 | haypo | set | nosy:
+ haypo messages: + msg117633 |
| 2010-08-19 18:44:52 | baikie | create | |
