]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Fix zone id corruption in Recursor JSON API 1279/head
authorChristian Hofstaedtler <christian@hofstaedtler.name>
Tue, 11 Feb 2014 21:07:59 +0000 (22:07 +0100)
committerChristian Hofstaedtler <christian@hofstaedtler.name>
Tue, 11 Feb 2014 21:07:59 +0000 (22:07 +0100)
pdns/ws-recursor.cc

index 53bbbf486a074d74bee3f05466b1d4a9b153e972..fc262d622a9ad62e653a1db1d11542cd4e6cc336 100644 (file)
@@ -119,7 +119,8 @@ static void fillZone(const string& zonename, HttpResponse* resp)
 
   // id is the canonical lookup key, which doesn't actually match the name (in some cases)
   string zoneId = apiZoneNameToId(iter->first);
-  doc.AddMember("id", zoneId.c_str(), doc.GetAllocator());
+  Value jzoneid(zoneId.c_str(), doc.GetAllocator()); // copy
+  doc.AddMember("id", jzoneid, doc.GetAllocator());
   string url = "/servers/localhost/zones/" + zoneId;
   Value jurl(url.c_str(), doc.GetAllocator()); // copy
   doc.AddMember("url", jurl, doc.GetAllocator());
@@ -271,7 +272,8 @@ static void apiServerZones(HttpRequest* req, HttpResponse* resp)
     jdi.SetObject();
     // id is the canonical lookup key, which doesn't actually match the name (in some cases)
     string zoneId = apiZoneNameToId(val.first);
-    jdi.AddMember("id", zoneId.c_str(), doc.GetAllocator());
+    Value jzoneid(zoneId.c_str(), doc.GetAllocator()); // copy
+    jdi.AddMember("id", jzoneid, doc.GetAllocator());
     string url = "/servers/localhost/zones/" + zoneId;
     Value jurl(url.c_str(), doc.GetAllocator()); // copy
     jdi.AddMember("url", jurl, doc.GetAllocator());