Skip to content

Commit 2d81291

Browse files
Vasily Gorbikgregkh
authored andcommitted
s390/extmem: fix gcc 8 stringop-overflow warning
[ Upstream commit 6b2ddf33baec23dace85bd647e3fc4ac070963e8 ] arch/s390/mm/extmem.c: In function '__segment_load': arch/s390/mm/extmem.c:436:2: warning: 'strncat' specified bound 7 equals source length [-Wstringop-overflow=] strncat(seg->res_name, " (DCSS)", 7); What gcc complains about here is the misuse of strncat function, which in this case does not limit a number of bytes taken from "src", so it is in the end the same as strcat(seg->res_name, " (DCSS)"); Keeping in mind that a res_name is 15 bytes, strncat in this case would overflow the buffer and write 0 into alignment byte between the fields in the struct. To avoid that increasing res_name size to 16, and reusing strlcat. Reviewed-by: Heiko Carstens <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]> Signed-off-by: Martin Schwidefsky <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 747128e commit 2d81291

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/s390/mm/extmem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct qin64 {
7979
struct dcss_segment {
8080
struct list_head list;
8181
char dcss_name[8];
82-
char res_name[15];
82+
char res_name[16];
8383
unsigned long start_addr;
8484
unsigned long end;
8585
atomic_t ref_count;
@@ -432,7 +432,7 @@ __segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long
432432
memcpy(&seg->res_name, seg->dcss_name, 8);
433433
EBCASC(seg->res_name, 8);
434434
seg->res_name[8] = '\0';
435-
strncat(seg->res_name, " (DCSS)", 7);
435+
strlcat(seg->res_name, " (DCSS)", sizeof(seg->res_name));
436436
seg->res->name = seg->res_name;
437437
rc = seg->vm_segtype;
438438
if (rc == SEG_TYPE_SC ||

0 commit comments

Comments
 (0)