Commit 682826b332fdaffaf814c2c6b3fa3dd1df39d139
Committed by
Ji Luo
1 parent
026360c2db
Exists in
smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga
and in
4 other branches
MA-14370 [coverity] Buffer not null terminated
Fix coverity issue: CID 43787: Buffer not null terminated (BUFFER_SIZE_WARNING) buffer_size_warning: Calling strncpy with a maximum size argument of 32 bytes on destination array sdev.name of size 32 bytes might leave the destination string unterminated. Test: Coverity scan pass. Change-Id: Ib10e631bab893cb9cd1484082229f806b02849ba Signed-off-by: Luo Ji <ji.luo@nxp.com>
Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff
drivers/serial/serial-uclass.c
... | ... | @@ -425,7 +425,7 @@ |
425 | 425 | return 0; |
426 | 426 | memset(&sdev, '\0', sizeof(sdev)); |
427 | 427 | |
428 | - strncpy(sdev.name, dev->name, sizeof(sdev.name)); | |
428 | + strncpy(sdev.name, dev->name, sizeof(sdev.name) - 1); | |
429 | 429 | sdev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_DM; |
430 | 430 | sdev.priv = dev; |
431 | 431 | sdev.putc = serial_stub_putc; |