Index: trunk/debs/pdns/debian/patches/10-fix-zoneparser-apostrophe-bug.dpatch |
— | — | @@ -0,0 +1,166 @@ |
| 2 | +#! /bin/sh /usr/share/dpatch/dpatch-run |
| 3 | +## 10-fix-zoneparser-apostrophe-bug.dpatch by <mark@mint.knams.wikimedia.org> |
| 4 | +## |
| 5 | +## All lines beginning with `## DP:' are a description of the patch. |
| 6 | +## DP: No description. |
| 7 | + |
| 8 | +@DPATCH@ |
| 9 | +diff -urNad pdns-2.9.21~/pdns/zoneparser-tng.cc pdns-2.9.21/pdns/zoneparser-tng.cc |
| 10 | +--- pdns-2.9.21~/pdns/zoneparser-tng.cc 2007-04-21 13:56:36.000000000 +0000 |
| 11 | +@@ -40,14 +40,16 @@ |
| 12 | + FILE *fp=fopen(fname.c_str(), "r"); |
| 13 | + if(!fp) |
| 14 | + throw runtime_error("Unable to open file '"+fname+"': "+stringerror()); |
| 15 | +- d_fps.push(fp); |
| 16 | ++ |
| 17 | ++ filestate fs(fp, fname); |
| 18 | ++ d_filestates.push(fs); |
| 19 | + } |
| 20 | + |
| 21 | + ZoneParserTNG::~ZoneParserTNG() |
| 22 | + { |
| 23 | +- while(!d_fps.empty()) { |
| 24 | +- fclose(d_fps.top()); |
| 25 | +- d_fps.pop(); |
| 26 | ++ while(!d_filestates.empty()) { |
| 27 | ++ fclose(d_filestates.top().d_fp); |
| 28 | ++ d_filestates.pop(); |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | +@@ -56,7 +58,23 @@ |
| 33 | + return string(line.c_str() + range.first, range.second - range.first); |
| 34 | + } |
| 35 | + |
| 36 | +-static unsigned int makeTTLFromZone(const string& str) |
| 37 | ++static bool isTimeSpec(const string& nextpart) |
| 38 | ++{ |
| 39 | ++ if(nextpart.empty()) |
| 40 | ++ return false; |
| 41 | ++ for(string::const_iterator iter = nextpart.begin(); iter != nextpart.end(); ++iter) { |
| 42 | ++ if(isdigit(*iter)) |
| 43 | ++ continue; |
| 44 | ++ if(iter+1 != nextpart.end()) |
| 45 | ++ return false; |
| 46 | ++ char c=tolower(*iter); |
| 47 | ++ return (c=='m' || c=='h' || c=='d' || c=='w' || c=='y'); |
| 48 | ++ } |
| 49 | ++ return true; |
| 50 | ++} |
| 51 | ++ |
| 52 | ++ |
| 53 | ++unsigned int ZoneParserTNG::makeTTLFromZone(const string& str) |
| 54 | + { |
| 55 | + if(str.empty()) |
| 56 | + return 0; |
| 57 | +@@ -80,8 +98,11 @@ |
| 58 | + case 'Y': // ? :-) |
| 59 | + val*=3600*24*365; |
| 60 | + break; |
| 61 | ++ |
| 62 | + default: |
| 63 | +- throw ZoneParserTNG::exception("Unable to parse time specification '"+str+"'"); |
| 64 | ++ throw ZoneParserTNG::exception("Unable to parse time specification '"+str+"' on line "+ |
| 65 | ++ lexical_cast<string>(d_filestates.top().d_lineno)+" of file '"+ |
| 66 | ++ d_filestates.top().d_filename+"'"); |
| 67 | + } |
| 68 | + return val; |
| 69 | + } |
| 70 | +@@ -198,6 +219,7 @@ |
| 71 | + } |
| 72 | + |
| 73 | + |
| 74 | ++ |
| 75 | + bool ZoneParserTNG::get(DNSResourceRecord& rr) |
| 76 | + { |
| 77 | + retry:; |
| 78 | +@@ -214,8 +236,8 @@ |
| 79 | + |
| 80 | + if(d_line[0]=='$') { |
| 81 | + string command=makeString(d_line, parts[0]); |
| 82 | +- if(command=="$TTL" && parts.size() > 1) |
| 83 | +- d_defaultttl=makeTTLFromZone(makeString(d_line,parts[1])); |
| 84 | ++ if(iequals(command,"$TTL") && parts.size() > 1) |
| 85 | ++ d_defaultttl=makeTTLFromZone(trim_right_copy_if(makeString(d_line, parts[1]), is_any_of(";"))); |
| 86 | + else if(iequals(command,"$INCLUDE") && parts.size() > 1) { |
| 87 | + string fname=unquotify(makeString(d_line, parts[1])); |
| 88 | + if(!fname.empty() && fname[0]!='/' && !d_reldir.empty()) |
| 89 | +@@ -239,7 +261,8 @@ |
| 90 | + goto retry; |
| 91 | + } |
| 92 | + else |
| 93 | +- throw exception("Can't parse zone line '"+d_line+"'"); |
| 94 | ++ throw exception("Can't parse zone line '"+d_line+"' on line "+lexical_cast<string>(d_filestates.top().d_lineno)+ |
| 95 | ++ " of file '"+d_filestates.top().d_filename); |
| 96 | + goto retry; |
| 97 | + } |
| 98 | + |
| 99 | +@@ -284,7 +307,7 @@ |
| 100 | + // cout<<"Ignoring 'IN'\n"; |
| 101 | + continue; |
| 102 | + } |
| 103 | +- if(!haveTTL && !haveQTYPE && all(nextpart, is_digit())) { |
| 104 | ++ if(!haveTTL && !haveQTYPE && isTimeSpec(nextpart)) { |
| 105 | + rr.ttl=makeTTLFromZone(nextpart); |
| 106 | + haveTTL=true; |
| 107 | + // cout<<"ttl is probably: "<<rr.ttl<<endl; |
| 108 | +@@ -300,7 +323,10 @@ |
| 109 | + continue; |
| 110 | + } |
| 111 | + catch(...) { |
| 112 | +- throw runtime_error("Parsing zone content line: '"+nextpart+"' doesn't look like a qtype, stopping loop"); |
| 113 | ++ throw runtime_error("Parsing zone content on line "+ |
| 114 | ++ lexical_cast<string>(d_filestates.top().d_lineno)+ |
| 115 | ++ " of file '"+d_filestates.top().d_filename+"': '"+nextpart+ |
| 116 | ++ "' doesn't look like a qtype, stopping loop"); |
| 117 | + } |
| 118 | + } |
| 119 | + if(!haveQTYPE) |
| 120 | +@@ -364,14 +390,15 @@ |
| 121 | + |
| 122 | + bool ZoneParserTNG::getLine() |
| 123 | + { |
| 124 | +- while(!d_fps.empty()) { |
| 125 | ++ while(!d_filestates.empty()) { |
| 126 | + char buffer[1024]; |
| 127 | +- if(fgets(buffer, 1024, d_fps.top())) { |
| 128 | ++ if(fgets(buffer, 1024, d_filestates.top().d_fp)) { |
| 129 | ++ d_filestates.top().d_lineno++; |
| 130 | + d_line=buffer; |
| 131 | + return true; |
| 132 | + } |
| 133 | +- fclose(d_fps.top()); |
| 134 | +- d_fps.pop(); |
| 135 | ++ fclose(d_filestates.top().d_fp); |
| 136 | ++ d_filestates.pop(); |
| 137 | + } |
| 138 | + return false; |
| 139 | + } |
| 140 | +diff -urNad pdns-2.9.21~/pdns/zoneparser-tng.hh pdns-2.9.21/pdns/zoneparser-tng.hh |
| 141 | +--- pdns-2.9.21~/pdns/zoneparser-tng.hh 2007-04-21 13:56:36.000000000 +0000 |
| 142 | +@@ -39,7 +39,7 @@ |
| 143 | + bool getLine(); |
| 144 | + bool getTemplateLine(); |
| 145 | + void stackFile(const std::string& fname); |
| 146 | +- stack<FILE *> d_fps; |
| 147 | ++ unsigned makeTTLFromZone(const std::string& str); |
| 148 | + string d_reldir; |
| 149 | + string d_line; |
| 150 | + string d_prevqname; |
| 151 | +@@ -48,6 +48,14 @@ |
| 152 | + uint32_t d_templatecounter, d_templatestop, d_templatestep; |
| 153 | + string d_templateline; |
| 154 | + parts_t d_templateparts; |
| 155 | ++ |
| 156 | ++ struct filestate { |
| 157 | ++ filestate(FILE* fp, string filename) : d_fp(fp), d_filename(filename), d_lineno(0){} |
| 158 | ++ FILE *d_fp; |
| 159 | ++ string d_filename; |
| 160 | ++ int d_lineno; |
| 161 | ++ }; |
| 162 | ++ stack<filestate> d_filestates; |
| 163 | + }; |
| 164 | + |
| 165 | + #endif |
Property changes on: trunk/debs/pdns/debian/patches/10-fix-zoneparser-apostrophe-bug.dpatch |
___________________________________________________________________ |
Added: svn:executable |
1 | 166 | + * |
Index: trunk/debs/pdns/debian/patches/00list |
— | — | @@ -1,2 +1,3 @@ |
2 | 2 | # Apply following patches |
3 | 3 | addconfigdir |
| 4 | +10-fix-zoneparser-apostrophe-bug |
Index: trunk/debs/pdns/debian/changelog |
— | — | @@ -1,3 +1,15 @@ |
| 2 | +pdns (2.9.21-1wm1) feisty; urgency=high |
| 3 | + |
| 4 | + * Incorporate zoneparser-tng parser fixes from r1056 |
| 5 | + |
| 6 | + -- Mark Bergsma <mark@wikimedia.org> Sun, 24 Jun 2007 14:51:00 +0000 |
| 7 | + |
| 8 | +pdns (2.9.21-1) feisty; urgency=medium |
| 9 | + |
| 10 | + * New upstream version 2.9.21 |
| 11 | + |
| 12 | + -- Mark Bergsma <mark@wikimedia.org> Sun, 24 Jun 2007 12:43:46 +0000 |
| 13 | + |
2 | 14 | pdns (2.9.20+r924-1) edgy; urgency=medium |
3 | 15 | |
4 | 16 | * Change upstream version to SVN revision 924 |