ref: 860a6fb41ae9a4d9513e77fc42b771d5decb0b0d
parent: 7a464a86ffcd8466d357d22675ff2bff70d045e6
author: rodri <rgl@antares-labs.eu>
date: Mon Mar 10 13:23:56 EDT 2025
fix unbounded substring search.
--- a/volume.c
+++ b/volume.c
@@ -69,13 +69,15 @@
Event e;
Point p;
double rad;
- int Etimer, key, d;
+ int n, Etimer, key, d;
char buf[32];
vfd = open("/dev/volume", ORDWR);
if(vfd < 0)
sysfatal("open: %r");
- read(vfd, buf, sizeof buf);
+ if((n = read(vfd, buf, sizeof(buf)-1)) <= 0)
+ sysfatal("read: %r");
+ buf[n] = 0;
ismixfs = strstr(buf, "mix") != nil;
update();
if(initdraw(0, 0, "volume") < 0)