Skip to contentSkip to conversation

alfred: Ensure processed change_iface packet is 0-terminated

PATCH New Sven Eckelmann 1 participant 1 message Feb 19, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 alfred: Ensure processed change_iface packet is 0-terminated

A client sending a alfred_change_interface_v0 packet to the alfred server might have forgotten to 0-terminate the string. In this case, strstr in unix_sock_change_iface might read outside of the available buffer.

---
 unix_sock.c | 2 ++
 1 file changed, 2 insertions(+)
unix_sock.c +2 -0
index bc39199..8c2b762 100644
@@ -329,6 +329,8 @@ unix_sock_change_iface(struct globals *globals,
 	if (len < (int)(sizeof(*change_iface) - sizeof(change_iface->header)))
 		goto err;
 
+	change_iface->ifaces[sizeof(change_iface->ifaces) - 1] = '\0';
+
 	if (globals->opmode == OPMODE_SECONDARY) {
 		if (strstr(change_iface->ifaces, ",") != NULL) {
 			ret = -EINVAL;
Signature · 1 line
2.30.2