diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-01-25 14:39:08 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-02-09 22:13:18 +0100 |
commit | dcfd984d8e09db9d5a7b4d121d914442966c254f (patch) | |
tree | b5807cd38c839423d8344596ddb77df6ce027b11 /misc-utils/mtdpart.c | |
parent | 83c675ac9aed767e4431a5bbc25f3ccd7f77cf84 (diff) |
mtd-utils: Fix potentially unterminated strings
This commit fixes some uses of strncpy that could leave the destination
buffer unterminated.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'misc-utils/mtdpart.c')
-rw-r--r-- | misc-utils/mtdpart.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/misc-utils/mtdpart.c b/misc-utils/mtdpart.c index e480e1b..ba35d87 100644 --- a/misc-utils/mtdpart.c +++ b/misc-utils/mtdpart.c @@ -174,7 +174,9 @@ int main(int argc, char * const argv[]) case COMMAND_ADD: part.start = start_addr; part.length = length; - strncpy(part.devname, part_name, sizeof(part.devname)); + strncpy(part.devname, part_name, + sizeof(part.devname) - 1); + part.devname[sizeof(part.devname) - 1] = '\0'; arg.op = BLKPG_ADD_PARTITION; break; case COMMAND_DEL: |