summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@eurephia.org>2014-12-05 15:54:20 +0100
committerDavid Sommerseth <dazo@eurephia.org>2014-12-05 16:02:10 +0100
commit3ddac122908f024e153abae83c232edf2d480f12 (patch)
tree02f1e30b2309173fd03d1163f2a2ee44a64a0362
parent0b6ecfd0c143d7d02d1fca5cd5774170dd321872 (diff)
downloadeurephia-3ddac122908f024e153abae83c232edf2d480f12.tar.gz
eurephia-3ddac122908f024e153abae83c232edf2d480f12.tar.xz
eurephia-3ddac122908f024e153abae83c232edf2d480f12.zip
Correct ugly boundary checks in database init
The check if dbargc exceeds MAX_ARGUMENTS was done _after_ it was checked if the array element is NULL. This was not the intention. Signed-off-by: David Sommerseth <dazo@eurephia.org> (cherry picked from commit 51f8c8e930221cc5feeac4f84be5550b4e5be9dd)
-rw-r--r--eurephiadm/eurephiadm.c2
-rw-r--r--plugin/eurephia.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/eurephiadm/eurephiadm.c b/eurephiadm/eurephiadm.c
index 6775a4f..f9deb31 100644
--- a/eurephiadm/eurephiadm.c
+++ b/eurephiadm/eurephiadm.c
@@ -250,7 +250,7 @@ int eurephia_ConnectDB(eurephiaCTX *ctx, const char *argstr) {
dbargc = 0;
dbargv[dbargc] = strtok(cp, delims);
- while( (dbargv[dbargc] != NULL) && (dbargc <= MAX_ARGUMENTS) ) {
+ while( (dbargc <= MAX_ARGUMENTS) && (dbargv[dbargc] != NULL) ) {
dbargv[++dbargc] = strtok(NULL, delims);
}
diff --git a/plugin/eurephia.c b/plugin/eurephia.c
index 880ad71..25af617 100644
--- a/plugin/eurephia.c
+++ b/plugin/eurephia.c
@@ -115,7 +115,7 @@ eurephiaCTX *eurephiaInit(const char const **argv, const char const **envp)
// Put the rest of the arguments into an own array which will be the db module arguments
if( optind < argc ) {
// copy arguments, but make sure we do not exceed our limit
- while( (optind < argc) && (dbargc < MAX_ARGUMENTS) ) {
+ while( (dbargc < MAX_ARGUMENTS) && (optind < argc) ) {
dbargv[dbargc] = argv[optind++];
dbargc++;
dbargv[dbargc] = NULL;