From: Stefan Reddig Date: Fri, 12 Mar 2010 17:14:55 +0000 (+0100) Subject: escaping,typo fix X-Git-Tag: Release-5.0.2~159 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5e9572441c8e71cd945402df6219e9641130ba7b;p=bacula%2Fbacula escaping,typo fix --- diff --git a/bacula/src/cats/ingres.c b/bacula/src/cats/ingres.c index a00b3f9353..45d4a3485a 100755 --- a/bacula/src/cats/ingres.c +++ b/bacula/src/cats/ingres.c @@ -313,21 +313,32 @@ int db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index) * NOTE! len is the length of the old string. Your new * string must be long enough (max 2*old+1) to hold * the escaped output. - * SRE: TODO! */ void db_escape_string(JCR *jcr, B_DB *mdb, char *snew, char *old, int len) { -/* - int error; - - PQescapeStringConn(mdb->db, snew, old, len, &error); - if (error) { - Jmsg(jcr, M_FATAL, 0, _("PQescapeStringConn returned non-zero.\n"));*/ - /* error on encoding, probably invalid multibyte encoding in the source string - see PQescapeStringConn documentation for details. */ -/* Dmsg0(500, "PQescapeStringConn failed\n"); - }*/ + char *n, *o; + + n = snew; + o = old; + while (len--) { + switch (*o) { + case '\'': + *n++ = '\''; + *n++ = '\''; + o++; + break; + case 0: + *n++ = '\\'; + *n++ = 0; + o++; + break; + default: + *n++ = *o++; + break; + } + } + *n = 0; } /* diff --git a/bacula/src/cats/myingres.c b/bacula/src/cats/myingres.c index 88d86d4fb6..0f5c64e238 100644 --- a/bacula/src/cats/myingres.c +++ b/bacula/src/cats/myingres.c @@ -1,7 +1,7 @@ #include "bacula.h" /* # line 3 "myingres.sc" */ #ifdef HAVE_INGRES -#include +#include #include extern IISQLCA sqlca; /* SQL Communications Area */ #include @@ -328,7 +328,7 @@ int INGfetchAll(const char *stmt, INGresult *ing_res) ++linecount; row->row_number = linecount; } - } while ( (sqlca.sqlcode == 0) || (sqlca.sqlcode == -40202) ) + } while ( (sqlca.sqlcode == 0) || (sqlca.sqlcode == -40202) ); /* # line 348 "myingres.sc" */ /* close */ { IIsqInit(&sqlca); @@ -347,7 +347,6 @@ ING_STATUS INGresultStatus(INGresult *res) void INGrowSeek(INGresult *res, int row_number) { ING_ROW *trow = NULL; - int i; if (res->act_row->row_number == row_number) { return; } @@ -357,7 +356,7 @@ void INGrowSeek(INGresult *res, int row_number) if (row_number<0 || row_number>res->num_rows) { return; } - for (trow = res->first_row , i=1 ; trow->row_number != row_number , i <= res->num_rows; trow = trow->next , ++i); + for (trow = res->first_row ; trow->row_number != row_number; trow = trow->next); res->act_row = trow; /* * Note - can be null - if row_number not found, right?