Patchwork [4/6] Properly NUL-terminate name in nfct_timeout_attr_set

login
register
mail settings
Submitter Jan Engelhardt
Date Feb. 29, 2012, 7:15 a.m.
Message ID <1330499742-28091-5-git-send-email-jengelh@medozas.de>
Download mbox | patch
Permalink /patch/143677/
State Accepted
Headers show

Comments

Jan Engelhardt - Feb. 29, 2012, 7:15 a.m.
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
 src/libnetfilter_cttimeout.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Patch

diff --git a/src/libnetfilter_cttimeout.c b/src/libnetfilter_cttimeout.c
index 707543a..1f7c63e 100644
--- a/src/libnetfilter_cttimeout.c
+++ b/src/libnetfilter_cttimeout.c
@@ -177,7 +177,8 @@  nfct_timeout_attr_set(struct nfct_timeout *t, uint32_t type, const void *data)
 {
 	switch(type) {
 	case NFCT_TIMEOUT_ATTR_NAME:
-		strncpy(t->name, data, 32);
+		strncpy(t->name, data, sizeof(t->name));
+		t->name[sizeof(t->name)-1] = '\0';
 		break;
 	case NFCT_TIMEOUT_ATTR_L3PROTO:
 		t->l3num = *((uint16_t *) data);