Repository : ssh://git@diktynna/alfred
On branch : master
commit adeaabdc909b774b1a507a180e909d8d0c0327b2 Author: Sven Eckelmann sven@narfation.org Date: Sat Feb 19 08:51:28 2022 +0100
alfred: Ensure printed interfaces in status are 0-terminated
A server sending a alfred_server_status_rep_v0 packet to the alfred client might have forgotten to 0-terminate the string. In this case, printf in alfred_client_server_status might read outside of the available buffer.
Fixes: 5a7d28b1866d ("alfred: introduce 'server status' IPC call") Signed-off-by: Sven Eckelmann sven@narfation.org
adeaabdc909b774b1a507a180e909d8d0c0327b2 client.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/client.c b/client.c index 8b8b968..bbe29ee 100644 --- a/client.c +++ b/client.c @@ -425,6 +425,7 @@ int alfred_client_server_status(struct globals *globals) break;
status_net_iface = (struct alfred_server_status_net_iface_v0 *)(buf + consumed); + status_net_iface->net_iface[sizeof(status_net_iface->net_iface) - 1] = 0; printf("- interface: %s\n", status_net_iface->net_iface); printf("\t- status: %s\n", status_net_iface->active == 1 ? "active" : "inactive"); @@ -434,6 +435,7 @@ int alfred_client_server_status(struct globals *globals) break;
status_bat_iface = (struct alfred_server_status_bat_iface_v0 *)(buf + consumed); + status_bat_iface->bat_iface[sizeof(status_bat_iface->bat_iface) - 1] = 0; printf("- batman-adv interface: %s\n", status_bat_iface->bat_iface); break; }