Module: check_mk
Branch: master
Commit: 92accd385c0cf864dc77f16f07aadba8efba6e50
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=92accd385c0cf8…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Dec 9 10:23:03 2015 +0100
Fixed potential out-of-bounds access in ends_with.
---
livestatus/src/strutil.cc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/livestatus/src/strutil.cc b/livestatus/src/strutil.cc
index e8473e2..5660570 100644
--- a/livestatus/src/strutil.cc
+++ b/livestatus/src/strutil.cc
@@ -104,7 +104,9 @@ char *save_next_token(char **c, char delim)
int ends_with(const char *a, const char *b)
{
- return !strcmp(a + strlen(a) - strlen(b), b);
+ size_t len_a = strlen(a);
+ size_t len_b = strlen(b);
+ return len_a >= len_b && strcmp(a + len_a - len_b, b) == 0;
}