Changeset 37

Show
Ignore:
Timestamp:
11/30/02 00:09:08 (10 years ago)
Author:
ahu
Message:

\' escaping bug

Location:
trunk/pdns
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/ChangeLog

    r19 r37  
    33        - added db2 backend to distribution 
    44        - added beginnings of ./configure autoconfiscation of mysql location 
     5        - fixed very embarrassing bug in bind parser - would die on escaping a ' 
    56 
    67Changes since 2.8: 
  • trunk/pdns/pdns/backends/bind/zone2sql.cc

    r36 r37  
    1919/* accepts a named.conf as parameter and outputs heaps of sql */ 
    2020 
    21 // $Id: zone2sql.cc,v 1.2 2002/11/29 22:50:56 ahu Exp $  
     21// $Id: zone2sql.cc,v 1.3 2002/11/29 23:09:08 ahu Exp $  
    2222#ifdef WIN32 
    2323# pragma warning ( disable: 4786 ) 
     
    4242StatBag S; 
    4343 
    44 string sqlstr(const string &str) 
    45 { 
    46   if(str.find("\'")!=string::npos) 
    47     throw 0; 
    48  
    49   string ret="\'"; 
    50   ret+=str; 
    51   ret+="\'"; 
    52   return ret; 
     44static const string sqlstr(const string &name) 
     45{ 
     46  string a="\'"; 
     47 
     48  for(string::const_iterator i=name.begin();i!=name.end();++i) 
     49    if(*i=='\'' || *i=='\\'){ 
     50      a+='\\'; 
     51      a+=*i; 
     52    } 
     53    else 
     54      a+=*i; 
     55  a+="\'"; 
     56  return a; 
    5357} 
    5458 
     
    263267    return 0; 
    264268  } 
     269  catch(exception &e) { 
     270    cerr<<"died because of STL error: "<<e.what()<<endl; 
     271    exit(0); 
     272  } 
    265273  catch(...) { 
    266     cerr<<"An unknown error occured"<<endl; 
    267     return 0; 
     274    cerr<<"died because of unknown exception"<<endl; 
     275    exit(0); 
    268276  } 
    269277