From 5f9558c222c0dfc8389f51892a3720791e55ed36 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 10 Feb 2020 19:30:45 +0100 Subject: [PATCH] Fix FTBFS and a couple of cleanups Fix FTBFS Resolves: rhbz#1799496 Fix wrong S-o-B tag in patch Fix warning about using unversioned Obsoletes Signed-off-by: Javier Martinez Canillas --- ...-about-possible-string-truncations-a.patch | 4 +- 0011-Fix-stringop-overflow-warning.patch | 72 +++++++++++++++++++ 0012-Fix-maybe-uninitialized-warning.patch | 35 +++++++++ grubby.spec | 12 +++- 4 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 0011-Fix-stringop-overflow-warning.patch create mode 100644 0012-Fix-maybe-uninitialized-warning.patch diff --git a/0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch b/0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch index 24d3d30..c4de866 100644 --- a/0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch +++ b/0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch @@ -1,5 +1,5 @@ From 00241c65a5c0b4bb32a847a6abb5a86d0c704a8f Mon Sep 17 00:00:00 2001 -From: no one +From: Javier Martinez Canillas Date: Tue, 5 Feb 2019 20:08:43 +0100 Subject: [PATCH] Fix GCC warnings about possible string truncations and buffer overflows @@ -10,7 +10,7 @@ leads to GCC complaining about possible string truncation and overflows. Fix this by using memcpy(), explicitly calculating the buffers lenghts and set a NUL byte terminator after copying the buffers. -Signed-off-by: no one +Signed-off-by: Javier Martinez Canillas --- grubby.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/0011-Fix-stringop-overflow-warning.patch b/0011-Fix-stringop-overflow-warning.patch new file mode 100644 index 0000000..0fc4734 --- /dev/null +++ b/0011-Fix-stringop-overflow-warning.patch @@ -0,0 +1,72 @@ +From ed5e255c023c9b78120d9ff2246d6516f652d4b7 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Mon, 10 Feb 2020 19:32:39 +0100 +Subject: [PATCH] Fix stringop-overflow warning + +GCC gives the following compile warning: + +grubby.c: In function 'main': +grubby.c:4508:27: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] + 4508 | saved_command_line[0] = '\0'; + | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~ +grubby.c:4503:26: note: at offset 0 to an object with size 0 allocated by 'malloc' here + 4503 | saved_command_line = malloc(i); + | ^~~~~~~~~ +cc1: all warnings being treated as errors +make: *** [Makefile:38: grubby.o] Error 1 + +Signed-off-by: Javier Martinez Canillas +--- + grubby.c | 35 +++++++++++++++++++---------------- + 1 file changed, 19 insertions(+), 16 deletions(-) + +diff --git a/grubby.c b/grubby.c +index 5ca689539cf..0c0f67a0ae5 100644 +--- a/grubby.c ++++ b/grubby.c +@@ -4500,23 +4500,26 @@ int main(int argc, const char ** argv) { + int i = 0; + for (int j = 1; j < argc; j++) + i += strlen(argv[j]) + 1; +- saved_command_line = malloc(i); +- if (!saved_command_line) { +- fprintf(stderr, "grubby: %m\n"); +- exit(1); +- } +- saved_command_line[0] = '\0'; +- int cmdline_len = 0, arg_len; +- for (int j = 1; j < argc; j++) { +- arg_len = strlen(argv[j]); +- memcpy(saved_command_line + cmdline_len, argv[j], arg_len); +- cmdline_len += arg_len; +- if (j != argc - 1) { +- memcpy(saved_command_line + cmdline_len, " ", 1); +- cmdline_len++; +- } ++ ++ if (i > 0) { ++ saved_command_line = malloc(i); ++ if (!saved_command_line) { ++ fprintf(stderr, "grubby: %m\n"); ++ exit(1); ++ } ++ saved_command_line[0] = '\0'; ++ int cmdline_len = 0, arg_len; ++ for (int j = 1; j < argc; j++) { ++ arg_len = strlen(argv[j]); ++ memcpy(saved_command_line + cmdline_len, argv[j], arg_len); ++ cmdline_len += arg_len; ++ if (j != argc - 1) { ++ memcpy(saved_command_line + cmdline_len, " ", 1); ++ cmdline_len++; ++ } ++ } ++ saved_command_line[cmdline_len] = '\0'; + } +- saved_command_line[cmdline_len] = '\0'; + + optCon = poptGetContext("grubby", argc, argv, options, 0); + poptReadDefaultConfig(optCon, 1); +-- +2.24.1 + diff --git a/0012-Fix-maybe-uninitialized-warning.patch b/0012-Fix-maybe-uninitialized-warning.patch new file mode 100644 index 0000000..bcaa145 --- /dev/null +++ b/0012-Fix-maybe-uninitialized-warning.patch @@ -0,0 +1,35 @@ +From ee9f80190d4c458a09309fbd9a88d2756dc2d3fa Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Mon, 10 Feb 2020 20:13:13 +0100 +Subject: [PATCH] Fix maybe-uninitialized warning + +GCC gives the following compile warning: + +grubby.c: In function 'suseGrubConfGetBoot': +grubby.c:2770:5: error: 'grubDevice' may be used uninitialized in this function [-Werror=maybe-uninitialized] + 2770 | free(grubDevice); + | ^~~~~~~~~~~~~~~~ +cc1: all warnings being treated as errors +make: *** [Makefile:38: grubby.o] Error 1 + +Signed-off-by: Javier Martinez Canillas +--- + grubby.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grubby.c b/grubby.c +index 0c0f67a0ae5..779c25a2bf9 100644 +--- a/grubby.c ++++ b/grubby.c +@@ -2755,7 +2755,7 @@ int grubGetBootFromDeviceMap(const char * device, + } + + int suseGrubConfGetBoot(const char * path, char ** bootPtr) { +- char * grubDevice; ++ char * grubDevice = NULL; + + if (suseGrubConfGetInstallDevice(path, &grubDevice)) + dbgPrintf("error looking for grub installation device\n"); +-- +2.24.1 + diff --git a/grubby.spec b/grubby.spec index 698f578..5011e98 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 39%{?dist} +Release: 40%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -24,6 +24,8 @@ Patch0007: 0007-Make-installkernel-to-use-kernel-install-scripts-on-.patch Patch0008: 0008-Add-usr-libexec-rpm-sort.patch Patch0009: 0009-Improve-man-page-for-info-option.patch Patch0010: 0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch +Patch0011: 0011-Fix-stringop-overflow-warning.patch +Patch0012: 0012-Fix-maybe-uninitialized-warning.patch BuildRequires: gcc BuildRequires: pkgconfig glib2-devel popt-devel @@ -42,7 +44,7 @@ Requires: s390utils-base Requires: findutils Requires: util-linux -Obsoletes: %{name}-bls +Obsoletes: %{name}-bls < %{version}-%{release} %description This package provides a grubby compatibility script that manages @@ -131,6 +133,12 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Mon Feb 10 2020 Javier Martinez Canillas - 8.40-40 +- Fix FTBFS + Resolves: rhbz#1799496 +- Fix wrong S-o-B tag in patch +- Fix warning about using unversioned Obsoletes + * Wed Jan 29 2020 Fedora Release Engineering - 8.40-39 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild