Changeset 7290

Show
Ignore:
Timestamp:
18/03/11 19:54:48 (14 months ago)
Author:
westram
Message:
  • GB_command_interpreter
    • when ACI contained backslashes, unescaping was wrong (resulting in buffer overflow)
    • nevertheless results from 'contains' (or maybe more ACI commands) may be wrong now (since they worked "correct" with wrong escaping)
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/dev/ARBDB/adquery.cxx

    r7289 r7290  
    941941                if (c=='\\') { 
    942942                    *(s2++) = c; 
    943                     if (!(c=*s1)) { break; } 
     943                    if (!(c=*++s1)) { break; } 
    944944                    *(s2++) = c; 
    945945                    continue; 
     
    10081008            } 
    10091009            else { 
    1010                 int argcparam = 0; 
    1011                 char *bracket = strchr(s1, '('); 
     1010                int   argcparam = 0; 
     1011                char *bracket   = strchr(s1, '('); 
     1012 
    10121013                if (bracket) {      // I got the parameter list 
    10131014                    int slen; 
     
    11811182#include <arbdbt.h> 
    11821183 
    1183 #define TEST_CI(input,cmd,expected) do {                               \ 
    1184         char *result; \ 
     1184#define TEST_CI__INTERNAL(input,cmd,expected,TEST_RESULT) do {          \ 
     1185        char *result;                                                   \ 
    11851186        TEST_ASSERT_RESULT__NOERROREXPORTED(result = GB_command_interpreter(gb_main, input, cmd, gb_data, NULL)); \ 
    1186         TEST_ASSERT_EQUAL(result,expected);                             \ 
     1187        TEST_RESULT(result,expected);                                   \ 
    11871188        free(result);                                                   \ 
    11881189    } while(0) 
     1190 
     1191 
     1192#define TEST_CI(input,cmd,expected)         TEST_CI__INTERNAL(input,cmd,expected,TEST_ASSERT_EQUAL) 
     1193#define TEST_CI__BROKEN(input,cmd,expected) TEST_CI__INTERNAL(input,cmd,expected,TEST_ASSERT_EQUAL__BROKEN) 
    11891194 
    11901195#define TEST_CI_ERROR(input,cmd,error_expected) do {                    \ 
     
    12281233 
    12291234        // escaping (@@@ wrong behavior?) 
    1230         TEST_CI("b\\a",   "|count(\\a)",    "2");   // i would expect '1' as result (the 'a'), but it counts '\\' and 'a' 
    1231         TEST_CI("b\\a",   "|contains(\\)",    "0"); // searches for 2 backslashes (should search for one) 
    1232         TEST_CI("b\\a",   "|contains(\"\\\\\")",    "0"); // searches for 2 backslashes 
     1235        TEST_CI("b\\a",   "|count(\\a)",         "2"); // i would expect '1' as result (the 'a'), but it counts '\\' and 'a' 
     1236        TEST_CI("b\\a",   "|contains(\"\\\\\")", "0"); // searches for 2 backslashes(ok) 
     1237        TEST_CI__BROKEN("b\\a", "|contains(\\)", "1"); // searches for 1 backslash (ok), but reports two hits instead of one 
     1238        TEST_CI__BROKEN("b\\\\a", "|contains(\"\\\\\")", "1"); // searches for 2 backslashes (ok), but reports two hits instead of one 
    12331239        TEST_CI_ERROR("b\\a", "|contains(\"\\\")", "ARB ERROR: unbalanced '\"' in '|contains(\"\\\")'"); // raises error (should searches for 1 backslash) 
    12341240