FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 10-25-2011, 12:08 PM
"Fabio M. Di Nitto"
 
Default config: improve string error checking in tokenizer

Spotted by Coverity Scan

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
:100644 100644 0a21f85... 710c176... M config/libs/libccsconfdb/xpathlite.c
config/libs/libccsconfdb/xpathlite.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/config/libs/libccsconfdb/xpathlite.c b/config/libs/libccsconfdb/xpathlite.c
index 0a21f85..710c176 100644
--- a/config/libs/libccsconfdb/xpathlite.c
+++ b/config/libs/libccsconfdb/xpathlite.c
@@ -15,13 +15,18 @@ static int tokenizer(char *current_query)
int tokens = 0;
char *curpos = current_query;
char *next = NULL;
- char *end;
+ char *end = NULL;

end = current_query + strlen(current_query);

while (curpos <= end) {
tokens++;

+ if (!curpos) {
+ errno = EINVAL;
+ return -1;
+ }
+
if (strncmp(curpos, "/", 1)) {
errno = EINVAL;
return -1;
@@ -39,11 +44,16 @@ static int tokenizer(char *current_query)
if (!next)
return tokens;

- if ((strstr(curpos, "[") > next) || !strstr(curpos, "["))
+ if ((strstr(curpos, "[") > next) || !strstr(curpos, "[")) {
curpos = next;
- else
- curpos = strstr(strstr(curpos, "]"), "/");
-
+ } else {
+ curpos = strstr(curpos, "]");
+ if (!curpos) {
+ errno = EINVAL;
+ return -1;
+ }
+ curpos = strstr(curpos, "/");
+ }
}
errno = EINVAL;
return -1;
--
1.7.4.4
 

Thread Tools




All times are GMT. The time now is 07:47 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org