diff options
author | Simon Howard | 2015-03-27 23:51:31 -0400 |
---|---|---|
committer | Simon Howard | 2015-03-27 23:51:31 -0400 |
commit | 0de4081d3b5689708136dd589d3554315e5ea6d1 (patch) | |
tree | 4fb486afc9d951aa0022675e5fd21eb9353f5f6e /src | |
parent | 9c17b1f6a1f89e33f80be2efacacbc3ce4380561 (diff) | |
download | chocolate-doom-0de4081d3b5689708136dd589d3554315e5ea6d1.tar.gz chocolate-doom-0de4081d3b5689708136dd589d3554315e5ea6d1.tar.bz2 chocolate-doom-0de4081d3b5689708136dd589d3554315e5ea6d1.zip |
misc: Handle M_StringCopy() short buffer case.
M_StringCopy() must always be provided a buffer of at least one
character long, so that a NUL character can be written. If this is
not the case, return immediately and indicate that the buffer was
truncated.
Diffstat (limited to 'src')
-rw-r--r-- | src/m_misc.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/m_misc.c b/src/m_misc.c index ab3c7009..53b86dba 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -379,6 +379,11 @@ boolean M_StringCopy(char *dest, const char *src, size_t dest_size) dest[dest_size - 1] = '\0'; strncpy(dest, src, dest_size - 1); } + else + { + return false; + } + len = strlen(dest); return src[len] == '\0'; } |