Skip to contentSkip to conversation

ipvsadm: Fix svc->pe_name conditional

PATCH Applied Ryan O'Hara 3 participants 3 messages Aug 19, 2013 – Aug 20, 2013 IPVS

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ipvsadm: Fix svc->pe_name conditional

The pe_name in ipvs_service_t is an array, so comparing it NULL has no effect. Check first byte of pe_name.

---
 libipvs/libipvs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
libipvs/libipvs.c +2 -2
index 2b066d2..89f26b9 100644
@@ -45,7 +45,7 @@ static int family, try_nl = 1;
 	{ errno = EAFNOSUPPORT; return ret; }			\
 	s->__addr_v4 = s->addr.ip;				\
 
-#define CHECK_PE(s, ret) if (s->pe_name)			\
+#define CHECK_PE(s, ret) if (s->pe_name[0])			\
 	{ errno = EAFNOSUPPORT; return ret; }
 
 #define CHECK_COMPAT_DEST(s, ret) CHECK_IPV4(s, ret)
@@ -234,7 +234,7 @@ static int ipvs_nl_fill_service_attr(struct nl_msg *msg, ipvs_service_t *svc)
 	}
 
 	NLA_PUT_STRING(msg, IPVS_SVC_ATTR_SCHED_NAME, svc->sched_name);
-	if (svc->pe_name)
+	if (svc->pe_name[0])
 		NLA_PUT_STRING(msg, IPVS_SVC_ATTR_PE_NAME, svc->pe_name);
 	NLA_PUT(msg, IPVS_SVC_ATTR_FLAGS, sizeof(flags), &flags);
 	NLA_PUT_U32(msg, IPVS_SVC_ATTR_TIMEOUT, svc->timeout);
Signature · 1 line
1.8.1.4
maintainer Acked-by on v2 1/1
#1 lore raw

Hello,

Quoted 4 lines · Ryan O'Hara

The pe_name in ipvs_service_t is an array, so comparing it NULL has no effect. Check first byte of pe_name.

Quoted 28 lines
---
 libipvs/libipvs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
libipvs/libipvs.c +2 -2
index 2b066d2..89f26b9 100644
@@ -45,7 +45,7 @@ static int family, try_nl = 1;
 	{ errno = EAFNOSUPPORT; return ret; }			\
 	s->__addr_v4 = s->addr.ip;				\
 
-#define CHECK_PE(s, ret) if (s->pe_name)			\
+#define CHECK_PE(s, ret) if (s->pe_name[0])			\
 	{ errno = EAFNOSUPPORT; return ret; }
 
 #define CHECK_COMPAT_DEST(s, ret) CHECK_IPV4(s, ret)
@@ -234,7 +234,7 @@ static int ipvs_nl_fill_service_attr(struct nl_msg *msg, ipvs_service_t *svc)
 	}
 
 	NLA_PUT_STRING(msg, IPVS_SVC_ATTR_SCHED_NAME, svc->sched_name);
-	if (svc->pe_name)
+	if (svc->pe_name[0])
 		NLA_PUT_STRING(msg, IPVS_SVC_ATTR_PE_NAME, svc->pe_name);
 	NLA_PUT(msg, IPVS_SVC_ATTR_FLAGS, sizeof(flags), &flags);
 	NLA_PUT_U32(msg, IPVS_SVC_ATTR_TIMEOUT, svc->timeout);
Signature · 1 line
1.8.1.4

Regards

--
Julian Anastasov <[email protected]>