diff options
| author | Edward Thomson <ethomson@microsoft.com> | 2013-08-08 11:05:00 -0500 |
|---|---|---|
| committer | Edward Thomson <ethomson@microsoft.com> | 2013-08-08 12:32:23 -0500 |
| commit | 57f31f058c29edfd7d6d810fcd4a964875e9d463 (patch) | |
| tree | 382c686e0418eb707ea6d5ce9b7fe02ead03965e /src/win32 | |
| parent | 5e96f31638fe71a0c76805b1352f437881791d98 (diff) | |
| download | libgit2-57f31f058c29edfd7d6d810fcd4a964875e9d463.tar.gz | |
Fixes to safely reading the index
Avoid wrapping around extension size when reading, avoid walking off
the end of the buffer when reading names.
Diffstat (limited to 'src/win32')
| -rw-r--r-- | src/win32/mingw-compat.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/win32/mingw-compat.h b/src/win32/mingw-compat.h index 7b97b48db..97b1cb71b 100644 --- a/src/win32/mingw-compat.h +++ b/src/win32/mingw-compat.h @@ -19,6 +19,11 @@ # define S_IFLNK _S_IFLNK # define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK) +GIT_INLINE(size_t) p_strnlen(const char *s, size_t maxlen) { + const char *end = memchr(s, 0, maxlen); + return end ? (end - s) : maxlen; +} + #endif #endif /* INCLUDE_mingw_compat__ */ |
