mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
d79448aefe
The 'Wlog_Error_String' string is defined to be 256 bytes in length, but in two places we write into it with a format that contains a string (wfile->w_file) that has length 1024. This can overflow Wlog_Error_String, as we see in the new compiler warnings from gcc 7.2.1: write_log.c:124:37: warning: ā%sā directive writing up to 1023 bytes into a region of size 224 [-Wformat-overflow=] "Could not open write_log - open(%s, %#o, %#o) failed: %s\n", ^~ Fix this by increasing the length of Wlog_Error_String to 1280 characters (1024 for wfile->w_file plus 256 for the rest of the format string), and by using snprintf() instead of sprintf() so we are sure we don't overflow. Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com> Reviewed-by: Eryu Guan <eguan@redhat.com> Signed-off-by: Eryu Guan <eguan@redhat.com>