Commit Graph

1868 Commits

Author SHA1 Message Date
b5d2296d5d Check for some obviously bad inputs from corrupt/malicious data.
These all caused crashes during fuzzing.
2020-04-28 13:28:45 -04:00
385b5d3cda stbi__stdio_eof() should check ferror(), too.
Otherwise with filesystem errors, you might end up with a short read but
believe there's still more to read from the file, causing infinite loops.
2020-04-28 13:25:57 -04:00
00f3f01be3 fseek() resets the EOF flag, even if seeking past the end of a read-only file.
This causes problems when stb_image tries to do this with stdio callbacks with
a maliciously crafted file (or just an unfortunately corrupt one)...

    // calls fread(), sets EOF flag, sets s->read_from_callbacks = 0
    stbi__refill_buffer(s);

    // calls fseek(), which resets the stream's EOF flag
    stbi__skip(some value we just read)

    // calls feof(), which always returns false because EOF flag was reset.
    while (!stbi__at_eof(s)) {
        // never calls fread() because s->read_from_callbacks==0
        stbi__refill_buffer(s);
        // loop forever
    }

To work around this, after seeking, we call fgetc(), which will set the EOF
flag as appropriate, and if not at EOF, we ungetc the byte so future reads
are correct. This fixes the infinite loop.
2020-04-28 13:25:57 -04:00
f54acd4e13 Merge branch 'working' 2020-02-05 04:32:20 -08:00
828e6cfdf7 update test 2020-02-05 04:31:55 -08:00
95671cca57 update version number 2020-02-05 03:41:17 -08:00
cd742941e6 stb_truetype: fix warning 2020-02-05 03:40:17 -08:00
37b9b20fde update version numbers 2020-02-05 03:19:08 -08:00
efdaadcb4a Merge branch 'master' of https://github.com/MarcoLizza/stb into working 2020-02-05 03:16:46 -08:00
2805fe39ab Merge branch 'fix_ub_shift' of https://github.com/wojdyr/stb into working 2020-02-05 03:15:56 -08:00
cb9d4e9547 sprintf: warning fixes 2020-02-05 03:15:41 -08:00
6b38abed1f Merge branch 'mine/avoid_warning' of https://github.com/wojdyr/stb into working 2020-02-05 03:10:20 -08:00
f06f586d18 sprintf warnings 2020-02-05 03:10:07 -08:00
41a6bb58d1 Other (pedantic) warnings for possible uninitialized variables. 2020-02-04 17:03:48 +01:00
43c6bd4e0e Fixing (pedantic) cast warnings. 2020-02-04 17:03:23 +01:00
6e8c31685f Fixing fall-trough (pedantic) warnings. 2020-02-04 16:59:47 +01:00
3366d1e797 stb_sprintf: avoid left shift of negative value
fix undefined behaviour reported by UBSan:
  runtime error: left shift of negative value -9223372036854775808
and add a test case.

fixes #800
2020-02-03 20:17:03 +01:00
3bb12a14e9 stb_sprintf.h: fix unused-parameter warning 2020-02-03 14:42:35 +01:00
498bd3e017 Fix typo in stbds_hmget_key_ts_wrapper 2020-02-03 16:17:42 +08:00
0224a44a10 stb_image: fix new warnings 2020-02-02 20:30:25 -08:00
0cbdb25d2b Merge branch 'master' of https://github.com/nothings/stb 2020-02-02 11:32:55 -08:00
dc664b1289 update readme 2020-02-02 11:32:21 -08:00
2bb4a0accd Fix trailing whitespace 2020-02-02 11:30:27 -08:00
7a69424f15 update version numbers 2020-02-02 11:26:50 -08:00
17c301817b Merge branch 'working' 2020-02-02 11:16:16 -08:00
8ee3beabba Merge branch 'master' of https://github.com/BSVino/stb into working 2020-02-02 11:16:06 -08:00
50dc48013b test stb_include.h 2020-02-02 11:12:27 -08:00
5e4a0617b7 udpate version numbers 2020-02-02 11:12:13 -08:00
d79349d0b7 stb_vorbis: update credits 2020-02-02 10:54:29 -08:00
95ce252305 Merge branch 'OggComment' of https://github.com/audinowho/stb into work2 2020-02-02 10:51:14 -08:00
49cbedfab6 LICENSE: remove trailign spaces 2020-02-02 10:36:08 -08:00
bd79d89de2 Merge branch 'patch-1' of https://github.com/Croydon/stb into work2 2020-02-02 10:11:53 -08:00
1ced9faea1 Merge branch 'unused-function-warnings' of https://github.com/BradleyMarie/stb into work2 2020-02-02 10:11:43 -08:00
d2569111cd Merge branch 'splitpath_raw_fix' of https://github.com/bcollins526/stb into work2 2020-02-02 10:06:31 -08:00
aad77ec74e Merge branch 'issue-799' of https://github.com/pwaller/stb into work2 2020-02-02 10:04:39 -08:00
a6726a3d28 Merge branch 'patch-1' of https://github.com/cshesse/stb into work2 2020-02-02 10:03:31 -08:00
24fdc35c90 stb_image_write: fix jpeg to work on non-C99 compilers 2020-02-02 10:02:53 -08:00
4067b6d28b Merge branch 'kc/fix-coverity-issues-1' of https://github.com/krcroft/stb into work2 2020-02-02 10:02:25 -08:00
6a6e028e26 Merge branch 'fix-vs2019-warning' of https://github.com/Reedbeta/stb into work2 2020-02-02 10:01:51 -08:00
454da539a2 Merge branch 'stbiw_update_jpeg' of https://github.com/DanielGibson/stb into work2 2020-02-02 10:01:04 -08:00
1586318a00 Merge branch 'master' of https://github.com/Try/stb into work2 2020-02-02 09:53:28 -08:00
cc99be2a9f Merge branch 'quell-clang-wcast-align' of https://github.com/a-e-k/stb into work2 2020-02-02 09:51:34 -08:00
fad1aa50c9 Merge branch 'fix-stb_include_strings' of https://github.com/sp0lsh/stb into work2 2020-02-02 09:46:48 -08:00
ca1b58154d Merge branch 'working' into work2 2020-02-02 09:45:56 -08:00
acd1c66aa4 Merge branch 'fix806' of https://github.com/kolbma/stb into work2 2020-02-02 09:45:35 -08:00
d882f542e9 Merge branch 'vorbis_seek_fixes' of https://github.com/dougallj/stb into work2 2020-02-02 09:44:21 -08:00
fd4f1f702e Merge branch 'master' of https://github.com/haferburg/stb into work2 2020-02-02 09:42:24 -08:00
95dc062d3f Merge branch 'cnlohr-fix-stb-include-newline' of https://github.com/cnlohr/stb into work2 2020-02-02 09:41:43 -08:00
15ae70a371 Merge branch 'work2' into working 2020-02-02 09:40:38 -08:00
69a39c14cc Merge branch 'fix-clang-warning' of https://github.com/zanshi/stb into work2 2020-02-02 09:40:26 -08:00