Commit e91cfe6
config.c: avoid integer truncation in
There are a couple of spots within `copy_or_rename_section_in_file()`
that incorrectly use an `int` to track an offset within a string, which
may truncate or wrap around to a negative value.
Historically it was impossible to have a line longer than 1024 bytes
anyway, since we used fgets() with a fixed-size buffer of exactly that
length. But the recent change to use a strbuf permits us to read lines
of arbitrary length, so it's possible for a malicious input to cause us
to overflow past INT_MAX and do an out-of-bounds array read.
Practically speaking, however, this should never happen, since it
requires 2GB section names or values, which are unrealistic in
non-malicious circumstances.
Co-authored-by: Jeff King <[email protected]>
Signed-off-by: Jeff King <[email protected]>
Signed-off-by: Taylor Blau <[email protected]>copy_or_rename_section_in_file()
1 parent a5bb10f commit e91cfe6
1 file changed
+5
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3027 | 3027 | | |
3028 | 3028 | | |
3029 | 3029 | | |
3030 | | - | |
| 3030 | + | |
3031 | 3031 | | |
3032 | | - | |
| 3032 | + | |
| 3033 | + | |
3033 | 3034 | | |
3034 | 3035 | | |
3035 | 3036 | | |
| |||
3133 | 3134 | | |
3134 | 3135 | | |
3135 | 3136 | | |
3136 | | - | |
3137 | | - | |
| 3137 | + | |
3138 | 3138 | | |
3139 | 3139 | | |
3140 | 3140 | | |
3141 | 3141 | | |
3142 | 3142 | | |
3143 | 3143 | | |
3144 | | - | |
| 3144 | + | |
3145 | 3145 | | |
3146 | 3146 | | |
3147 | 3147 | | |
| |||
0 commit comments