3 ms·
> The second part of the problem (and this is the actual vulnerability) is that track_set_index does not check that i ≥ 0 … and then we check that `i` is posit
by deathanatos 3y ago
> The second part of the problem (and this is the actual vulnerability) is that track_set_index does not check that i ≥ 0
… and then we check that `i` is positive, instead of using the proper type of size_t, which avoids the entire problem of negative indexes from the get go. (Though size_t doesn't save you from having to write a decent parser…)
The post also notes how the code fails to check for failures during parsing while calling atoi (mainly because atoi is one of those garbage-tier functions in C's stdlib that you should never call, in this case because it is incapable of signalling errors) … but then does nothing about it. So even after this patch, atoi can still return random garbage and in some cases the parser will just happily keep on using that. (But it shouldn't access random memory, I suppose.)