Fix buffer overflow when displaying measurements
This commit is contained in:
1 parent
bc3967ccb6
commit
e7efcee289
1 file changed
+1
-1
@@ -247,7 +247,7 @@ static void print_measurements(int on)
|
|||||||
memset(line_color + width - MAX_UNIT_LEN, 4, MAX_UNIT_LEN); /* blue */
|
memset(line_color + width - MAX_UNIT_LEN, 4, MAX_UNIT_LEN); /* blue */
|
||||||
else
|
else
|
||||||
memset(line_color + width - MAX_UNIT_LEN, 3, MAX_UNIT_LEN); /* yellow */
|
memset(line_color + width - MAX_UNIT_LEN, 3, MAX_UNIT_LEN); /* yellow */
|
||||||
memcpy(line + width - MAX_UNIT_LEN + 1, text, MAX(strlen(text), MAX_UNIT_LEN));
|
memcpy(line + width - MAX_UNIT_LEN + 1, text, MIN(strlen(text), MAX_UNIT_LEN - 1));
|
||||||
display_line(on, width);
|
display_line(on, width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user