From 72386012200a96f9bb721ab4ddb5a9325c68c5f7 Mon Sep 17 00:00:00 2001 From: Varsha Rao Date: Wed, 20 Sep 2017 21:53:09 +0530 Subject: src: Buffer is null terminated. In _snprintf() functions definition the buffer is null terminated. Signed-off-by: Varsha Rao Signed-off-by: Pablo Neira Ayuso --- src/obj/counter.c | 3 +++ src/obj/ct_helper.c | 3 +++ src/obj/limit.c | 3 +++ src/obj/quota.c | 3 +++ 4 files changed, 12 insertions(+) (limited to 'src/obj') diff --git a/src/obj/counter.c b/src/obj/counter.c index beadc93..332bb2b 100644 --- a/src/obj/counter.c +++ b/src/obj/counter.c @@ -158,6 +158,9 @@ static int nftnl_obj_counter_snprintf(char *buf, size_t len, uint32_t type, uint32_t flags, const struct nftnl_obj *e) { + if (len) + buf[0] = '\0'; + switch (type) { case NFTNL_OUTPUT_DEFAULT: return nftnl_obj_counter_snprintf_default(buf, len, e); diff --git a/src/obj/ct_helper.c b/src/obj/ct_helper.c index d6d3111..62569fe 100644 --- a/src/obj/ct_helper.c +++ b/src/obj/ct_helper.c @@ -185,6 +185,9 @@ static int nftnl_obj_ct_helper_snprintf(char *buf, size_t len, uint32_t type, uint32_t flags, const struct nftnl_obj *e) { + if (len) + buf[0] = '\0'; + switch (type) { case NFTNL_OUTPUT_DEFAULT: return nftnl_obj_ct_helper_snprintf_default(buf, len, e); diff --git a/src/obj/limit.c b/src/obj/limit.c index 8cf0faa..7f8bcf7 100644 --- a/src/obj/limit.c +++ b/src/obj/limit.c @@ -212,6 +212,9 @@ static int nftnl_obj_limit_snprintf(char *buf, size_t len, uint32_t type, uint32_t flags, const struct nftnl_obj *e) { + if (len) + buf[0] = '\0'; + switch (type) { case NFTNL_OUTPUT_DEFAULT: return nftnl_obj_limit_snprintf_default(buf, len, e); diff --git a/src/obj/quota.c b/src/obj/quota.c index d5757b2..6d36784 100644 --- a/src/obj/quota.c +++ b/src/obj/quota.c @@ -179,6 +179,9 @@ static int nftnl_obj_quota_snprintf(char *buf, size_t len, uint32_t type, uint32_t flags, const struct nftnl_obj *e) { + if (len) + buf[0] = '\0'; + switch (type) { case NFTNL_OUTPUT_DEFAULT: return nftnl_obj_quota_snprintf_default(buf, len, e); -- cgit v1.2.3