Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-04-16 01:09:38 +0300
committerMichael Niedermayer <michael@niedermayer.cc>2019-11-11 22:18:45 +0300
commit32c200d49dc7a05db9e3a9199cc845f574b2f63b (patch)
tree0f692052338114b364b7e8db80883efa1eada1c5 /libavutil
parent17d039349f892195b2854b45d7ee691ee6c85b81 (diff)
avutil/avstring: Fix bug and undefined behavior in av_strncasecmp()
The function in case of n=0 would read more bytes than 0. The end pointer could be beyond the allocated space, which is undefined. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 6f0e9a863466bfcbd75ee15d4d8a6aad2a5126a4) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/avstring.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavutil/avstring.c b/libavutil/avstring.c
index f03dd25141..4c068f5bc5 100644
--- a/libavutil/avstring.c
+++ b/libavutil/avstring.c
@@ -222,12 +222,13 @@ int av_strcasecmp(const char *a, const char *b)
int av_strncasecmp(const char *a, const char *b, size_t n)
{
- const char *end = a + n;
uint8_t c1, c2;
+ if (n <= 0)
+ return 0;
do {
c1 = av_tolower(*a++);
c2 = av_tolower(*b++);
- } while (a < end && c1 && c1 == c2);
+ } while (--n && c1 && c1 == c2);
return c1 - c2;
}