--- parser3/src/main/untaint.C 2001/10/11 10:21:44 1.68 +++ parser3/src/main/untaint.C 2001/10/29 16:29:08 1.71 @@ -4,7 +4,7 @@ Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: untaint.C,v 1.68 2001/10/11 10:21:44 parser Exp $ + $Id: untaint.C,v 1.71 2001/10/29 16:29:08 paf Exp $ */ #include "pa_pool.h" @@ -148,7 +148,15 @@ inline bool need_quote_http_header(const @todo fix potential forigins_mode buf overrun */ size_t String::cstr_bufsize(Untaint_lang lang) const { - return (lang==UL_AS_IS?size():size()*UNTAINT_TIMES_BIGGER*(forigins_mode?10:1)) +1; + return ( + lang==UL_AS_IS? + size() + : + size() + *UNTAINT_TIMES_BIGGER + *(forigins_mode?10:1) + ) + +1; } /** @todo fix theoretical \n mem overrun in TYPO replacements @@ -164,7 +172,7 @@ char *String::store_to(char *dest, Untai const Chunk *chunk=&head; do { const Chunk::Row *row=chunk->rows; - for(size_t i=0; icount; i++, row++) { + for(uint i=0; icount; i++, row++) { if(row==append_here) goto break2; @@ -195,12 +203,12 @@ char *String::store_to(char *dest, Untai const char *src=row->item.ptr; for(int size=row->item.size; size--; src++) switch(*src) { - case ' ': case '\n': case '\t': + /***case ' ': case '\n': case '\t': if(!whitespace) { *dest++=*src; whitespace=true; } - break; + break;*/ default: whitespace=false; *dest++=*src; @@ -275,7 +283,7 @@ char *String::store_to(char *dest, Untai if(connection) dest+=connection->quote(dest, row->item.ptr, row->item.size); else - THROW(0, 0, + throw Exception(0, 0, this, "untaint in SQL language failed - no connection specified"); break; @@ -311,12 +319,12 @@ char *String::store_to(char *dest, Untai case UL_USER_HTML: { // tainted, untaint language: html-typo if(!typo_dict) // never, always has default - THROW(0, 0, + throw Exception(0, 0, this, "untaint to user-html lang failed, no typo table"); char *html_for_typo= - (char *)malloc(row->item.size*2/* '\n' -> '\' 'n' */+1); + (char *)malloc(row->item.size*2/* '\n' -> '\' 'n' */+1,16); // note: // there still is a possibility that user // would not replace \n as she supposed to @@ -348,7 +356,7 @@ char *String::store_to(char *dest, Untai // b allowed to be max UNTAINT_TIMES_BIGGER then a if(b.size()>UNTAINT_TIMES_BIGGER*a.size()) { pool().set_tag(0); // avoid recursion - THROW(0, 0, + throw Exception(0, 0, &b, "is %g times longer then '%s', " "while maximum, handled by Parser, is %d", @@ -369,7 +377,7 @@ char *String::store_to(char *dest, Untai break; } default: - THROW(0, 0, + throw Exception(0, 0, this, "unknown untaint language #%d of %d piece", static_cast(row->item.lang),