diff options
author | Simon Howard | 2010-04-18 18:48:48 +0000 |
---|---|---|
committer | Simon Howard | 2010-04-18 18:48:48 +0000 |
commit | 59bc6523b4869e515aefa9118715cd440b163fc4 (patch) | |
tree | cf8f15db5c75c718655e96d1b0cba234487caf59 | |
parent | fe49cfc004026cdf92c58056079f68a01ba99c7f (diff) | |
download | chocolate-doom-59bc6523b4869e515aefa9118715cd440b163fc4.tar.gz chocolate-doom-59bc6523b4869e515aefa9118715cd440b163fc4.tar.bz2 chocolate-doom-59bc6523b4869e515aefa9118715cd440b163fc4.zip |
Fix unsigned integer overflow with calls to M_StrCaseStr where
strlen(haystack) < strlen(needle)
Subversion-branch: /branches/raven-branch
Subversion-revision: 1906
-rw-r--r-- | src/m_misc.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/m_misc.c b/src/m_misc.c index 9d3144b2..ed41b5f1 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -263,12 +263,20 @@ void M_ForceUppercase(char *text) char *M_StrCaseStr(char *haystack, char *needle) { + unsigned int haystack_len; unsigned int needle_len; unsigned int len; unsigned int i; + haystack_len = strlen(haystack); needle_len = strlen(needle); - len = strlen(haystack) - needle_len; + + if (haystack_len < needle_len) + { + return NULL; + } + + len = haystack_len - needle_len; for (i = 0; i <= len; ++i) { |