]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix const-correctness of dnsdist_ffi_raw_value_t's value 11078/head auth-4.7.0-alpha0
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 8 Dec 2021 11:41:23 +0000 (12:41 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 8 Dec 2021 11:41:23 +0000 (12:41 +0100)
This prevent an allocation and a copy since we can now directly pass
a Lua string.

pdns/dnsdistdist/dnsdist-lua-ffi-interface.h
regression-tests.dnsdist/test_Spoofing.py

index e371d9e1db1c7c2beaee83552c428c08f6f7b987..71faeb12f99bc196ebb28967c29262d03ac58466 100644 (file)
@@ -44,7 +44,7 @@ typedef struct dnsdist_ffi_tag {
 } dnsdist_ffi_tag_t;
 
 typedef struct dnsdist_ffi_raw_value {
-  char* value;
+  const char* value;
   uint16_t size;
 } dnsdist_ffi_raw_value_t;
 
index cc86e6bff3898bfa623354cf142fdaede27586fb..9a3e10d2d48a7dfa64a35e6a0186f09ce2f81cb6 100644 (file)
@@ -773,12 +773,10 @@ class TestSpoofingLuaFFISpoofMulti(DNSDistTest):
 
             local str = "\\192\\000\\002\\001"
             records[0].size = #str
-            records[0].value = ffi.new("char[?]", #str)
-            ffi.copy(records[0].value, str, #str)
+            records[0].value = str
 
             local str = "\\192\\000\\002\\255"
-            records[1].value = ffi.new("char[?]", #str)
-            ffi.copy(records[1].value, str, #str)
+            records[1].value = str
             records[1].size = #str
 
             ffi.C.dnsdist_ffi_dnsquestion_spoof_raw(dq, records, 2)
@@ -788,13 +786,11 @@ class TestSpoofingLuaFFISpoofMulti(DNSDistTest):
 
             local str = "\\033this text has a comma at the end,"
             records[0].size = #str
-            records[0].value = ffi.new("char[?]", #str)
-            ffi.copy(records[0].value, str, #str)
+            records[0].value = str
 
             local str = "\\003aaa\\004bbbb"
             records[1].size = #str
-            records[1].value = ffi.new("char[?]", #str)
-            ffi.copy(records[1].value, str, #str)
+            records[1].value = str
 
             ffi.C.dnsdist_ffi_dnsquestion_spoof_raw(dq, records, 2)
             return DNSAction.HeaderModify