summaryrefslogtreecommitdiffstats
path: root/disk-utils
diff options
context:
space:
mode:
authorKarel Zak2019-05-14 15:00:01 +0200
committerKarel Zak2019-05-14 15:00:01 +0200
commit89770db4ef94dd990e718fa8ce5b0a33f54c3237 (patch)
treed897464fccaab57319d26ad47db124a0e9003155 /disk-utils
parentbuild-sys: add --with-pkgconfigdir (diff)
downloadkernel-qcow2-util-linux-89770db4ef94dd990e718fa8ce5b0a33f54c3237.tar.gz
kernel-qcow2-util-linux-89770db4ef94dd990e718fa8ce5b0a33f54c3237.tar.xz
kernel-qcow2-util-linux-89770db4ef94dd990e718fa8ce5b0a33f54c3237.zip
fdisk: initialize buffers for get_user_reply() [coverity scan]
It's probably unnecessary, but better be safe than sorry. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils')
-rw-r--r--disk-utils/fdisk-menu.c2
-rw-r--r--disk-utils/fdisk.c4
-rw-r--r--disk-utils/sfdisk.c4
3 files changed, 5 insertions, 5 deletions
diff --git a/disk-utils/fdisk-menu.c b/disk-utils/fdisk-menu.c
index a6f43515f..cd104e20b 100644
--- a/disk-utils/fdisk-menu.c
+++ b/disk-utils/fdisk-menu.c
@@ -417,7 +417,7 @@ int process_fdisk_menu(struct fdisk_context **cxt0)
const struct menu *menu;
int key, rc;
const char *prompt;
- char buf[BUFSIZ];
+ char buf[BUFSIZ] = { '\0' };
if (fdisk_is_details(cxt))
prompt = _("Expert command (m for help): ");
diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c
index c27485af2..380f3f445 100644
--- a/disk-utils/fdisk.c
+++ b/disk-utils/fdisk.c
@@ -397,7 +397,7 @@ int ask_callback(struct fdisk_context *cxt, struct fdisk_ask *ask,
void *data __attribute__((__unused__)))
{
int rc = 0;
- char buf[BUFSIZ];
+ char buf[BUFSIZ] = { '\0' };
assert(cxt);
assert(ask);
@@ -482,7 +482,7 @@ static struct fdisk_parttype *ask_partition_type(struct fdisk_context *cxt, int
_("Hex code (type L to list all codes): ") :
_("Partition type (type L to list all types): ");
do {
- char buf[256];
+ char buf[256] = { '\0' };
int rc = get_user_reply(q, buf, sizeof(buf));
if (rc) {
diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
index 8166137c5..4a9640d0e 100644
--- a/disk-utils/sfdisk.c
+++ b/disk-utils/sfdisk.c
@@ -133,7 +133,7 @@ static int get_user_reply(const char *prompt, char *buf, size_t bufsz)
p = readline(prompt);
if (!p)
return 1;
- strncpy(buf, p, bufsz);
+ strncpy(buf, p, bufsz - 1);
if (bufsz != 0)
buf[bufsz - 1] = '\0';
free(p);
@@ -192,7 +192,7 @@ static int ask_callback(struct fdisk_context *cxt __attribute__((__unused__)),
break;
case FDISK_ASKTYPE_YESNO:
{
- char buf[BUFSIZ];
+ char buf[BUFSIZ] = { '\0' };
fputc('\n', stdout);
do {
int x;