mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
dasdfmt: fix buffer overread warning
dasdfmt.c: In function ‘dasdfmt_write_labels’:
dasdfmt.c:1110:22: warning: ‘write’ reading 88 bytes from a region of size 4 [-Wstringop-overread]
1110 | rc = write(fd, &vlabel->vollbl, (sizeof(*vlabel)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1111 | - sizeof(vlabel->volkey)));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from dasdfmt.c:23:
../include/lib/vtoc.h:84:14: note: source object ‘vollbl’ of size 4
84 | char vollbl[4]; /* volume label */
| ^~~~~~
In file included from ../include/lib/util_opt.h:16,
from dasdfmt.c:20:
/usr/include/unistd.h:378:16: note: in a call to function ‘write’ declared with attribute ‘access (read_only, 2, 3)’
378 | extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur
| ^~~~~
GitHub-ID: https://github.com/ibm-s390-linux/s390-tools/pull/137
Signed-off-by: Dan Horák <dan@danny.cz>
Acked-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
@@ -1107,8 +1107,8 @@ static void dasdfmt_write_labels(volume_label_t *vlabel,
|
||||
} else {
|
||||
vlabel->ldl_version = 0xf2; /* EBCDIC '2' */
|
||||
vlabel->formatted_blocks = cylinders * heads * geo.sectors;
|
||||
rc = write(fd, &vlabel->vollbl, (sizeof(*vlabel)
|
||||
- sizeof(vlabel->volkey)));
|
||||
rc = write(fd, (void *)vlabel + sizeof(vlabel->volkey),
|
||||
(sizeof(*vlabel) - sizeof(vlabel->volkey)));
|
||||
}
|
||||
|
||||
if (((rc != sizeof(*vlabel) - sizeof(vlabel->formatted_blocks)) &&
|
||||
|
||||
Reference in New Issue
Block a user