path: root/py/
diff options
authorPhil Sutter <>2018-06-18 10:11:46 +0200
committerPablo Neira Ayuso <>2018-06-18 11:18:02 +0200
commit4677971a01dc4d92087dab139428cf4eaa189536 (patch)
tree6f287f244a935755cf004f737b2b850694820871 /py/
parent5ca7ad252366865225d5c59d297e71215b68f027 (diff)
libnftables: Simplify nft_run_cmd_from_buffer footprint
With libnftables documentation being upstream and one confirmed external user (nftlb), time to break the API! First of all, the command buffer passed to nft_run_cmd_from_buffer may (and should) be const. One should consider it a bug if that function ever changed it's content. On the other hand, there is no point in passing the buffer's length as separate argument: NULL bytes are not expected to occur in the input, so it is safe to rely upon strlen(). Also, the actual parsers don't require a buffer length passed to them, either. The only use-case for it is when reallocating the buffer to append a final newline character, there strlen() is perfectly sufficient. Suggested-by: Harald Welte <> Cc: Laura Garcia Liebana <> Cc: Eric Leblond <> Cc: Arturo Borrero Gonzalez <> Signed-off-by: Phil Sutter <> Signed-off-by: Pablo Neira Ayuso <>
Diffstat (limited to 'py/')
1 files changed, 2 insertions, 2 deletions
diff --git a/py/ b/py/
index 47ff14af..e6e66fb7 100644
--- a/py/
+++ b/py/
@@ -100,7 +100,7 @@ class Nftables:
self.nft_run_cmd_from_buffer = lib.nft_run_cmd_from_buffer
self.nft_run_cmd_from_buffer.restype = c_int
- self.nft_run_cmd_from_buffer.argtypes = [c_void_p, c_char_p, c_int]
+ self.nft_run_cmd_from_buffer.argtypes = [c_void_p, c_char_p]
self.nft_ctx_free = lib.nft_ctx_free
lib.nft_ctx_free.argtypes = [c_void_p]
@@ -267,7 +267,7 @@ 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, len(cmdline))
+ 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)