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 <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2020-02-10 19:30:45 +01:00
parent 03b13cef75
commit 5f9558c222
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69
4 changed files with 119 additions and 4 deletions

View File

@ -1,5 +1,5 @@
From 00241c65a5c0b4bb32a847a6abb5a86d0c704a8f Mon Sep 17 00:00:00 2001 From 00241c65a5c0b4bb32a847a6abb5a86d0c704a8f Mon Sep 17 00:00:00 2001
From: no one <noone@example.com> From: Javier Martinez Canillas <javierm@redhat.com>
Date: Tue, 5 Feb 2019 20:08:43 +0100 Date: Tue, 5 Feb 2019 20:08:43 +0100
Subject: [PATCH] Fix GCC warnings about possible string truncations and buffer Subject: [PATCH] Fix GCC warnings about possible string truncations and buffer
overflows 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 Fix this by using memcpy(), explicitly calculating the buffers lenghts
and set a NUL byte terminator after copying the buffers. and set a NUL byte terminator after copying the buffers.
Signed-off-by: no one <noone@example.com> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
--- ---
grubby.c | 35 +++++++++++++++++++++++++++-------- grubby.c | 35 +++++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 8 deletions(-) 1 file changed, 27 insertions(+), 8 deletions(-)

View File

@ -0,0 +1,72 @@
From ed5e255c023c9b78120d9ff2246d6516f652d4b7 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
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 <javierm@redhat.com>
---
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

View File

@ -0,0 +1,35 @@
From ee9f80190d4c458a09309fbd9a88d2756dc2d3fa Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
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 <javierm@redhat.com>
---
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

View File

@ -1,6 +1,6 @@
Name: grubby Name: grubby
Version: 8.40 Version: 8.40
Release: 39%{?dist} Release: 40%{?dist}
Summary: Command line tool for updating bootloader configs Summary: Command line tool for updating bootloader configs
License: GPLv2+ License: GPLv2+
URL: https://github.com/rhinstaller/grubby 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 Patch0008: 0008-Add-usr-libexec-rpm-sort.patch
Patch0009: 0009-Improve-man-page-for-info-option.patch Patch0009: 0009-Improve-man-page-for-info-option.patch
Patch0010: 0010-Fix-GCC-warnings-about-possible-string-truncations-a.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: gcc
BuildRequires: pkgconfig glib2-devel popt-devel BuildRequires: pkgconfig glib2-devel popt-devel
@ -42,7 +44,7 @@ Requires: s390utils-base
Requires: findutils Requires: findutils
Requires: util-linux Requires: util-linux
Obsoletes: %{name}-bls Obsoletes: %{name}-bls < %{version}-%{release}
%description %description
This package provides a grubby compatibility script that manages This package provides a grubby compatibility script that manages
@ -131,6 +133,12 @@ current boot environment.
%{_mandir}/man8/*.8* %{_mandir}/man8/*.8*
%changelog %changelog
* Mon Feb 10 2020 Javier Martinez Canillas <javierm@redhat.com> - 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 <releng@fedoraproject.org> - 8.40-39 * Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-39
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild