[PATCH nft] py: fix missing decode/encode of strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When calling ffi functions we need to convert from python strings to
utf-8. Then convert back for any output we receive.

Fixes: 586ad210368b7 ("libnftables: Implement JSON parser")
Signed-off-by: Eric Garver <eric@xxxxxxxxxxx>
---
 py/nftables.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/py/nftables.py b/py/nftables.py
index f07163573f9a..dea417e587d6 100644
--- a/py/nftables.py
+++ b/py/nftables.py
@@ -352,9 +352,9 @@ class Nftables:
         output -- a string containing output written to stdout
         error  -- a string containing output written to stderr
         """
-        rc = self.nft_run_cmd_from_buffer(self.__ctx, cmdline)
-        output = self.nft_ctx_get_output_buffer(self.__ctx)
-        error = self.nft_ctx_get_error_buffer(self.__ctx)
+        rc = self.nft_run_cmd_from_buffer(self.__ctx, cmdline.encode("utf-8"))
+        output = self.nft_ctx_get_output_buffer(self.__ctx).decode("utf-8")
+        error = self.nft_ctx_get_error_buffer(self.__ctx).decode("utf-8")
 
         return (rc, output, error)
 
-- 
2.20.1




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux