~kroq-gar78/ubuntu/precise/rsyslog/fix-846818

« back to all changes in this revision

Viewing changes to template.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2008-07-23 02:22:32 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080723022232-496osxty0v9vvw9g
Tags: 3.18.1-1
* New upstream release. Closes: #490445
  - List Debian in doc/rsyslog_packages.html. Closes: #488870
  - Fix compilation of imklog module on GNU/kFreeBSD. Closes: #491193
* debian/rsyslog-doc.install
  - Install the example config file. Closes: #488860
* debian/rules
  - Enable mail output plugin.
  - Make sure all directories are created by calling dh_installdirs for both
    binary-arch and binary-indep. Closes: #491459
* debian/rsyslog.install
  - Install mail output plugin (ommail.so).
* debian/control
  - Add Suggests www-browser to rsyslog-doc as the package contains mostly
    html documents.
  - Update feature list.
  - Adjust priorities, set rsyslog priority to important.

Show diffs side-by-side

added added

removed removed

Lines of Context:
188
188
 * new parameter escapeMode is 0 - standard sql, 1 - "smart" engines
189
189
 * 2005-09-22 rgerhards
190
190
 */
191
 
void doSQLEscape(uchar **pp, size_t *pLen, unsigned short *pbMustBeFreed, int escapeMode)
 
191
rsRetVal
 
192
doSQLEscape(uchar **pp, size_t *pLen, unsigned short *pbMustBeFreed, int escapeMode)
192
193
{
 
194
        DEFiRet;
193
195
        uchar *p;
194
196
        int iLen;
195
 
        cstr_t *pStrB;
 
197
        cstr_t *pStrB = NULL;
196
198
        uchar *pszGenerated;
197
199
 
198
200
        assert(pp != NULL);
210
212
        /* when we get out of the loop, we are either at the
211
213
         * string terminator or the first \'. */
212
214
        if(*p == '\0')
213
 
                return; /* nothing to do in this case! */
 
215
                FINALIZE; /* nothing to do in this case! */
214
216
 
215
217
        p = *pp;
216
218
        iLen = *pLen;
217
 
        if(rsCStrConstruct(&pStrB) != RS_RET_OK) {
218
 
                /* oops - no mem ... Do emergency... */
219
 
                doSQLEmergencyEscape(p, escapeMode);
220
 
                return;
221
 
        }
 
219
        CHKiRet(rsCStrConstruct(&pStrB));
222
220
        
223
221
        while(*p) {
224
222
                if(*p == '\'') {
225
 
                        if(rsCStrAppendChar(pStrB, (escapeMode == 0) ? '\'' : '\\') != RS_RET_OK) {
226
 
                                doSQLEmergencyEscape(*pp, escapeMode);
227
 
                                rsCStrDestruct(&pStrB);
228
 
                                return;
229
 
                                }
 
223
                        CHKiRet(rsCStrAppendChar(pStrB, (escapeMode == 0) ? '\'' : '\\'));
230
224
                        iLen++; /* reflect the extra character */
231
225
                } else if((escapeMode == 1) && (*p == '\\')) {
232
 
                        if(rsCStrAppendChar(pStrB, '\\') != RS_RET_OK) {
233
 
                                doSQLEmergencyEscape(*pp, escapeMode);
234
 
                                rsCStrDestruct(&pStrB);
235
 
                                return;
236
 
                                }
 
226
                        CHKiRet(rsCStrAppendChar(pStrB, '\\'));
237
227
                        iLen++; /* reflect the extra character */
238
228
                }
239
 
                if(rsCStrAppendChar(pStrB, *p) != RS_RET_OK) {
240
 
                        doSQLEmergencyEscape(*pp, escapeMode);
241
 
                        rsCStrDestruct(&pStrB);
242
 
                        return;
243
 
                }
 
229
                CHKiRet(rsCStrAppendChar(pStrB, *p));
244
230
                ++p;
245
231
        }
246
 
        rsCStrFinish(pStrB);
247
 
        if(rsCStrConvSzStrAndDestruct(pStrB, &pszGenerated, 0) != RS_RET_OK) {
248
 
                doSQLEmergencyEscape(*pp, escapeMode);
249
 
                return;
250
 
        }
 
232
        CHKiRet(rsCStrFinish(pStrB));
 
233
        CHKiRet(rsCStrConvSzStrAndDestruct(pStrB, &pszGenerated, 0));
251
234
 
252
235
        if(*pbMustBeFreed)
253
236
                free(*pp); /* discard previous value */
255
238
        *pp = pszGenerated;
256
239
        *pLen = iLen;
257
240
        *pbMustBeFreed = 1;
 
241
 
 
242
finalize_it:
 
243
        if(iRet != RS_RET_OK) {
 
244
                doSQLEmergencyEscape(*pp, escapeMode);
 
245
                if(pStrB != NULL)
 
246
                        rsCStrDestruct(&pStrB);
 
247
        }
 
248
 
 
249
        RETiRet;
258
250
}
259
251
 
260
252
 
385
377
        if((pTpe = tpeConstruct(pTpl)) == NULL) {
386
378
                /* OK, we are out of luck. Let's invalidate the
387
379
                 * entry and that's it.
388
 
                 * TODO: add panic message once we have a mechanism for this
389
380
                 */
390
381
                pTpe->eEntryType = UNDEFINED;
391
382
                return 1;
453
444
                        pTpe->data.field.eCaseConv = tplCaseConvLower;
454
445
                 } else if(!strcmp((char*)Buf, "uppercase")) {
455
446
                        pTpe->data.field.eCaseConv = tplCaseConvUpper;
 
447
                 } else if(!strcmp((char*)Buf, "sp-if-no-1st-sp")) {
 
448
                        pTpe->data.field.options.bSPIffNo1stSP = 1;
456
449
                 } else if(!strcmp((char*)Buf, "escape-cc")) {
457
450
                        pTpe->data.field.options.bEscapeCC = 1;
458
451
                 } else if(!strcmp((char*)Buf, "drop-cc")) {
510
503
        pTpe->eEntryType = FIELD;
511
504
 
512
505
        while(*p && *p != '%' && *p != ':') {
513
 
                rsCStrAppendChar(pStrB, *p++);
 
506
                rsCStrAppendChar(pStrB, tolower(*p));
 
507
                ++p; /* do NOT do this in tolower()! */
514
508
        }
515
509
 
516
510
        /* got the name*/
1021
1015
                                if(pTpe->data.field.options.bSpaceCC) {
1022
1016
                                        dbgprintf("[replace control-characters with space] ");
1023
1017
                                }
 
1018
                                if(pTpe->data.field.options.bSecPathDrop) {
 
1019
                                        dbgprintf("[slashes are dropped] ");
 
1020
                                }
 
1021
                                if(pTpe->data.field.options.bSecPathReplace) {
 
1022
                                        dbgprintf("[slashes are replaced by '_'] ");
 
1023
                                }
 
1024
                                if(pTpe->data.field.options.bSPIffNo1stSP) {
 
1025
                                        dbgprintf("[SP iff no first SP] ");
 
1026
                                }
1024
1027
                                if(pTpe->data.field.options.bDropLastLF) {
1025
1028
                                        dbgprintf("[drop last LF in msg] ");
1026
1029
                                }