Commit Graph

13574 Commits

Author SHA1 Message Date
Karel Zak 106e696064 lsblk: make sure __process_one_device() has proper arguments [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 12:36:53 +02:00
Karel Zak 74152bf944 lsblk: check ul_path_scanf() return value [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 12:31:49 +02:00
Karel Zak 404eef654a lsblk: check stat() return code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 12:28:13 +02:00
Karel Zak 7241dda191 logger: make code more robust for static analyzer [clang scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 12:14:10 +02:00
Karel Zak ac255c2b14 hardlink: avoid uninitialized variables [clang scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 12:12:07 +02:00
Sami Kerola 620851e0cc
libfdisk: assert if self_pte() returns NULL
The self_pte() can return NULL if partitions array is not large enough,
but that should also be impossible and definitely a bug.

libfdisk/src/dos.c:984:8: warning: potential null pointer dereference [-Wnull-dereference]
libfdisk/src/dos.c:1031:8: warning: potential null pointer dereference [-Wnull-dereference]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-22 19:45:54 +01:00
Karel Zak 04d0701ea8 libfdisk: (bsd) improve checksum calculation [-Waddress-of-packed-member]
Let's keep compilers and static analyzers happy. The idea is to use
memcpy() to copy from buffer to variable and use all label as unsigned
char rather than vectorize by unsigned short.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-22 17:47:04 +02:00
Karel Zak 16d7868fc1 libblkid: (silicon raid) improve checksum calculation [-Waddress-of-packed-member]
Let's keep compilers and static analyzers happy. The idea is to use
memcpy() to copy from buffer to variable and use all label as unsigned
char rather than vectorize by uint16_t.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-22 17:46:14 +02:00
Karel Zak 1a56f15b0f libfdisk: (sgi) improve checksum calculation [-Waddress-of-packed-member]
Let's keep compilers and static analyzers happy. The idea is to use
memcpy() to copy from buffer to variable and use all label as unsigned
char rather than vectorize by uint32_t.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-22 17:42:48 +02:00
Karel Zak 34b0a305f6 include/c: use __has_attribute
The __has macros are more portable (supported by gcc as well as
clang).

The old __GNUC_PREREQ is deprecated and it should be removed in
future. (Well, the __has macros are supported since gcc 5, so we
should be patient as some old stable distros (e.g. RHEL 7) use gcc
4.x).

This patch helps clang to correctly analyze our xalloc.h stuff.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-21 16:27:17 +02:00
Sami Kerola 2e56aa3c3b
bash-completion: add hardlink completion
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-20 19:56:19 +01:00
Sami Kerola ba5e7b7e52
bash-completion: update options before release
blkid: 5e91d5dd71 --no-part-details
lsblk: dc4662f0e7 --dedup
lsblk: 0bd05f5ee4 --merge
lscpu: 0e86bc8406 --caches
lscpu: 2011528bce --bytes

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-20 19:43:59 +01:00
Karel Zak 8ecc6ba807 lib/ismounted: use xstrncpy()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-20 13:03:58 +02:00
Karel Zak 380fe6ac46 zramctl: use xstrncpy()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-20 12:59:40 +02:00
Karel Zak aa75c5eb74 whereis: use xstrncpy()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-20 12:59:02 +02:00
Karel Zak 124a903002 vipw: use xstrncpy()
It's already used by vipw, so use it everywhere.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-20 12:57:39 +02:00
Karel Zak e2569bcf26 lib/path: use xstrncpy()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-20 12:57:16 +02:00
Karel Zak 94d9fd9f6a lib/sysfs: use xstrncpy()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-20 12:57:07 +02:00
Karel Zak 91072cd480 losetup: use xstrncpy()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-20 12:46:39 +02:00
Karel Zak 9f34182d53 sfdisk: use xstrcpy()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-20 12:42:43 +02:00
Karel Zak 9d6852d3a2 lib/colors: remove unnecessary goto
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-20 12:41:12 +02:00
Karel Zak 002931c485 Merge branch '2019wk19' of https://github.com/kerolasa/util-linux
* '2019wk19' of https://github.com/kerolasa/util-linux:
  lib/colors: remove redundant if statement
  wipefs: fix variable / function shadowing [cppcheck]
  sulogin: fix variable / function shadowing [cppcheck]
  lscpu: remove redundant condition check [cppcheck]
  libmount: avoid possible null pointer dereference [cppcheck]
  lib/mangle: fix possible null pointer dereference [cppcheck]
  sfdisk: remove unnecessary size check [cppcheck]
2019-05-20 12:35:38 +02:00
Karel Zak fbae15802e Merge branch 'lscpu_midr_updates' of https://github.com/jlinton/util-linux
* 'lscpu_midr_updates' of https://github.com/jlinton/util-linux:
  lscpu: Add additional aarch64 models
2019-05-20 12:35:09 +02:00
Karel Zak 353931a2c1 Merge branch 'lscpu-another' of https://github.com/kerolasa/util-linux
* 'lscpu-another' of https://github.com/kerolasa/util-linux:
  lscpu: fix floating point exception
  include/strutils: fix potential null pointer dereference
  lscpu: remove extra space from field key name
2019-05-20 12:34:45 +02:00
Sami Kerola cc7ffe129d
lib/colors: remove redundant if statement
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-18 22:56:15 +01:00
Sami Kerola 9abc8a42aa
wipefs: fix variable / function shadowing [cppcheck]
[misc-utils/wipefs.c:636] -> [misc-utils/wipefs.c:310]: (style) Local
variable usage shadows outer function

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-18 22:42:13 +01:00
Sami Kerola ff09a5129a
sulogin: fix variable / function shadowing [cppcheck]
[login-utils/sulogin.c:398] -> [login-utils/sulogin.c:171]: (style) Local
variable set shadows outer function
[login-utils/sulogin.c:398] -> [login-utils/sulogin.c:830]: (style) Local
variable set shadows outer function

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-18 22:41:58 +01:00
Sami Kerola 6dd7b74b3b
lscpu: remove redundant condition check [cppcheck]
[sys-utils/lscpu.c:1783] -> [sys-utils/lscpu.c:1785]: (warning) Either the
condition 'desc' is redundant or there is possible null pointer dereference: desc.
[sys-utils/lscpu.c:1840] -> [sys-utils/lscpu.c:1842]: (warning) Either the
condition 'desc' is redundant or there is possible null pointer dereference: desc.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-18 22:26:09 +01:00
Sami Kerola cbcedf6ba8
libmount: avoid possible null pointer dereference [cppcheck]
[libmount/src/monitor.c:797]: (warning) Possible null pointer dereference: me

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-18 22:17:10 +01:00
Sami Kerola 4f807791ee
lib/mangle: fix possible null pointer dereference [cppcheck]
Fix effects code that is used when testing util-linux, so quite low impact.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-18 22:09:25 +01:00
Sami Kerola 84f46d1f67
sfdisk: remove unnecessary size check [cppcheck]
Following warning is false positive.  Size of the buffer is defined using
BUFSIZ, and so the strncpy() will never overwrite the last byte that is
initialized to zero in get_user_reply().

[disk-utils/sfdisk.c:137] -> [disk-utils/sfdisk.c:136]: (warning) Either the
condition 'bufsz!=0' is redundant or strncpy() argument nr 3 can have
invalid value.  The value is -1 but the valid values are '0:'.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-18 22:07:20 +01:00
Sami Kerola 23df051030
lscpu: fix floating point exception
As the title tells this change indeed fixes floating point exception, but
post processing as value overwrite feels a wrong.  Possibly something in
input is making cpu set count to go wrong, but I could not get my head
around what could it be.  Anyway avoiding division by zero seems better than
crashing so lets do this atleast for now.

Caused-by: e5f721132e
Addresses: https://github.com/karelzak/util-linux/issues/788
Reported-by: Lars Wendler <polynomial-c@gentoo.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-18 18:43:08 +01:00
Sami Kerola d2a1ee4e56
include/strutils: fix potential null pointer dereference
Recent lscpu fix caused gcc -Wnull-dereference to go off that this change
addresses.

Reference: b94acada9e
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-16 22:05:07 +01:00
Sami Kerola 30d5ceeda8
lscpu: remove extra space from field key name
The extra space was more obvious in json output.  But as the expected test
output displays also the standard output can be effected by this change.

    $ lscpu --json | jq '.lscpu | .[].field' | grep ': '
    "L1d cache: "
    "L1i cache: "
    "L2 cache: "
    "L3 cache: "
    "Vulnerability L1tf: "
    "Vulnerability Mds: "
    "Vulnerability Meltdown: "
    "Vulnerability Spec store bypass: "
    "Vulnerability Spectre v1: "
    "Vulnerability Spectre v2: "

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-16 22:04:03 +01:00
Jeremy Linton 8d124f0fc7 lscpu: Add additional aarch64 models
ARM has released docs for Cortex-A76, Neoverse-N1 and Neoverse-E1.
That means we know the midr partnums, so we can add them to the
human readable model name table.

Signed-off-by: Jeremy Linton <lintonrjeremy@gmail.com>
2019-05-16 12:10:17 -05:00
Karel Zak 778e2b2b7f findmnt: keep it easy for static analyzers 2019-05-16 14:38:12 +02:00
Karel Zak 097c067f5c findmnt: (verify) check mnt_table_next_fs() return code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-16 14:33:47 +02:00
Karel Zak 374cb54381 fincore: remove unused variable [clang scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-16 14:27:15 +02:00
Karel Zak f06d8b69a9 cal: make sure months_in_row makes sense [coverity scan]
* avoid divide by zero in mountly() dues to wrong months_in_row
* make sure months_in_row is at least 1

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-16 14:22:43 +02:00
Karel Zak fa1b64da96 blkid: improve strcpy() usage [coverity scan]
The old deprecated list output format ("-o list") copies gettex string
into fixed buffer, that's really bad idea.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-16 13:56:34 +02:00
Karel Zak e868cfb0a6 utmpdump: check ftello() return value
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-16 13:46:03 +02:00
Karel Zak 4ac2ab97d1 Merge branch 'lscpu-output-fix' of https://github.com/kerolasa/util-linux
* 'lscpu-output-fix' of https://github.com/kerolasa/util-linux:
  lscpu: move trailing null after removing characters from a string
2019-05-16 13:31:30 +02:00
Sami Kerola b94acada9e
lscpu: move trailing null after removing characters from a string
From the test input string ':' characters are removed:

    cat x86_64-epyc_7451/sys/devices/system/cpu/vulnerabilities/spectre_v2
    Mitigation: Full AMD retpoline, IBPB: conditional, STIBP: disabled, RSB filling

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-16 11:45:47 +01:00
Karel Zak e2a0f26341 libsmartcols: (groups) improve scols_table_group_lines() args check [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-15 17:46:31 +02:00
Karel Zak cb400752a4 libmount: fix memory leak on error [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-15 17:25:04 +02:00
Karel Zak f11eedf527 libfdisk: avoid memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-15 17:12:38 +02:00
Karel Zak 845fd622ed libfdisk: avoid division by zero [clang scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-15 17:10:38 +02:00
Karel Zak 1d161441c2 libfdisk: remove unused code [clang scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-15 16:59:52 +02:00
Karel Zak 7f3a98229b libfdisk: properly check return code of add_to_partitions_array() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-15 16:49:26 +02:00
Karel Zak 5b3b21128c libblkid: make partitions reference counting more robust [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-15 16:28:31 +02:00