]> git.ipfire.org Git - thirdparty/util-linux.git/commit - disk-utils/mkswap.c
mkswap: do not use uninitialized stack value
authorSamanta Navarro <ferivoz@riseup.net>
Fri, 13 Jan 2023 11:53:41 +0000 (11:53 +0000)
committerSamanta Navarro <ferivoz@riseup.net>
Fri, 13 Jan 2023 11:54:54 +0000 (11:54 +0000)
commit6c88722c175adca5b1a72bcc770f94674405b7f4
tree7036708c6653db9dd75cdd76a059dce72c093e70
parentfaeb1b64b36ededd1a0b62555cad65f002d47ac6
mkswap: do not use uninitialized stack value

If blkdev_get_size fails, then size is not set. Exit with an error code
and indicate what went wrong instead of continuing with random stack
content.

Proof of Concept:

```
$ mkswap /dev/null
mkswap: warning: truncating swap area to 17179869180 KiB
mkswap: /dev/null: insecure permissions 0666, fix with: chmod 0600 /dev/null
mkswap: unable to assign device to libblkid probe
```

The first output line depends on stack content and sometimes does not
show up at all. Abort operation if argument is neither regular file nor
block device.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
disk-utils/mkswap.c