From b314ec0e39804ffe797f3badca4e9705e1c2e0d8 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Sun, 3 Feb 2013 07:08:46 -0700 Subject: [PATCH] Fix segmentation fault on missing squid.conf values Directves expecting percentage values may segfault when no value token is supplied. Detected by Coverity Scan. Issue 970941 --- src/Parsing.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Parsing.cc b/src/Parsing.cc index ab67afa198..2ed440b1f0 100644 --- a/src/Parsing.cc +++ b/src/Parsing.cc @@ -191,6 +191,11 @@ GetPercentage(void) int p; char *token = strtok(NULL, w_space); + if (!token) { + debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT), "ERROR: A percentage value is missing."); + self_destruct(); + } + //if there is a % in the end of the digits, we remove it and go on. char* end = &token[strlen(token)-1]; if (*end == '%') { -- 2.47.2