From: Wilfried Göesgens Date: Wed, 16 Jan 2008 22:10:55 +0000 (+0000) Subject: * if the token extractor fails to do its work, rather return '0' than some random... X-Git-Tag: v7.86~2590 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=5bea7a9acf7af5c9c0fcd03a78e2f96192f92064 * if the token extractor fails to do its work, rather return '0' than some random number. --- diff --git a/libcitadel/lib/tools.c b/libcitadel/lib/tools.c index 8298d9d48..e07b60fee 100644 --- a/libcitadel/lib/tools.c +++ b/libcitadel/lib/tools.c @@ -228,8 +228,10 @@ int extract_int(const char *source, int parmnum) { char buf[32]; - extract_token(buf, source, parmnum, '|', sizeof buf); - return(atoi(buf)); + if (extract_token(buf, source, parmnum, '|', sizeof buf) > 0) + return(atoi(buf)); + else + return 0; } /* @@ -239,8 +241,10 @@ long extract_long(const char *source, int parmnum) { char buf[32]; - extract_token(buf, source, parmnum, '|', sizeof buf); - return(atol(buf)); + if (extract_token(buf, source, parmnum, '|', sizeof buf) > 0) + return(atol(buf)); + else + return 0; } @@ -251,8 +255,10 @@ unsigned long extract_unsigned_long(const char *source, int parmnum) { char buf[32]; - extract_token(buf, source, parmnum, '|', sizeof buf); - return strtoul(buf, NULL, 10); + if (extract_token(buf, source, parmnum, '|', sizeof buf) > 0) + return strtoul(buf, NULL, 10); + else + return 0; }