From 258bd85ae9c121a5bc16e05e8082d515c8a8b65a Mon Sep 17 00:00:00 2001 From: Zhao Hang Date: Tue, 5 Dec 2023 14:29:47 +0800 Subject: [PATCH 1/5] update to grubby-8.40-48.src.rpm Signed-off-by: Zhao Hang --- 0001-grubby-anolis-rebrand.patch | 25 ---- ...-about-possible-string-truncations-a.patch | 107 ------------------ 1002-Fix-stringop-overflow-warning.patch | 73 ------------ grubby-bls | 4 +- grubby.spec | 25 +--- 5 files changed, 8 insertions(+), 226 deletions(-) delete mode 100644 0001-grubby-anolis-rebrand.patch delete mode 100644 1001-Fix-GCC-warnings-about-possible-string-truncations-a.patch delete mode 100644 1002-Fix-stringop-overflow-warning.patch diff --git a/0001-grubby-anolis-rebrand.patch b/0001-grubby-anolis-rebrand.patch deleted file mode 100644 index 672fb28..0000000 --- a/0001-grubby-anolis-rebrand.patch +++ /dev/null @@ -1,25 +0,0 @@ -From e0d8ccc74c0567fb0b319bedf9d10c5ec7def0b7 Mon Sep 17 00:00:00 2001 -From: yangxiaoxuan -Date: Tue, 26 Jan 2021 05:42:20 +0800 -Subject: [PATCH] grubby anolis rebrand - ---- - new-kernel-pkg | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/new-kernel-pkg b/new-kernel-pkg -index 0fe6caa..512ac2a 100755 ---- a/new-kernel-pkg -+++ b/new-kernel-pkg -@@ -162,6 +162,8 @@ set_title() { - title="$NAME ($version) $VERSION" - elif [ -f /etc/redhat-release ]; then - title="$(sed 's/ release.*$//' < /etc/redhat-release) ($version)" -+ elif [ -f /etc/anolis-release ]; then -+ title="$(sed 's/ release.*$//' < /etc/anolis-release) ($version)" - else - title="Red Hat Linux ($version)" - fi --- -2.18.2 - diff --git a/1001-Fix-GCC-warnings-about-possible-string-truncations-a.patch b/1001-Fix-GCC-warnings-about-possible-string-truncations-a.patch deleted file mode 100644 index db16955..0000000 --- a/1001-Fix-GCC-warnings-about-possible-string-truncations-a.patch +++ /dev/null @@ -1,107 +0,0 @@ -From 9a2fc457659cc2baee7d13ed6b0f8c864ae605d9 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 5 Feb 2019 17:29:11 +0100 -Subject: [PATCH] Fix GCC warnings about possible string truncations and buffer - overflows - -Building with -Werror=stringop-truncation and -Werror=stringop-overflow -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: Javier Martinez Canillas ---- - grubby.c | 38 ++++++++++++++++++++++++++++++-------- - 1 file changed, 30 insertions(+), 8 deletions(-) - -diff --git a/grubby.c b/grubby.c -index 396041a..947b458 100644 ---- a/grubby.c -+++ b/grubby.c -@@ -479,20 +479,28 @@ char *grub2ExtractTitle(struct singleLine *line) - snprintf(result, resultMaxSize, "%s", ++current); - - i++; -+ int result_len = 0; - for (; i < line->numElements; ++i) { - current = line->elements[i].item; - current_len = strlen(current); - current_indent = line->elements[i].indent; - current_indent_len = strlen(current_indent); - -- strncat(result, current_indent, current_indent_len); -+ memcpy(result + result_len, current_indent, current_indent_len); -+ result_len += current_indent_len; -+ - if (current[current_len - 1] != quote_char) { -- strncat(result, current, current_len); -+ memcpy(result + result_len, current_indent, -+ current_indent_len); -+ result_len += current_len; - } else { -- strncat(result, current, current_len - 1); -+ memcpy(result + result_len, current_indent, -+ current_indent_len); -+ result_len += (current_len - 1); - break; - } - } -+ result[result_len] = '\0'; - return result; - } - -@@ -1437,6 +1445,7 @@ static struct grubConfig *readConfig(const char *inName, - extras = malloc(len + 1); - *extras = '\0'; - -+ int buf_len = 0; - /* get title. */ - for (int i = 0; i < line->numElements; i++) { - if (!strcmp -@@ -1453,13 +1462,18 @@ static struct grubConfig *readConfig(const char *inName, - - len = strlen(title); - if (title[len - 1] == quote_char) { -- strncat(buf, title, len - 1); -+ memcpy(buf + buf_len, title, len - 1); -+ buf_len += (len - 1); - break; - } else { -- strcat(buf, title); -- strcat(buf, line->elements[i].indent); -+ memcpy(buf + buf_len, title, len); -+ buf_len += len; -+ len = strlen(line->elements[i].indent); -+ memcpy(buf + buf_len, line->elements[i].indent, len); -+ buf_len += len; - } - } -+ buf[buf_len] = '\0'; - - /* get extras */ - int count = 0; -@@ -5209,10 +5223,18 @@ int main(int argc, const char **argv) - exit(1); - } - saved_command_line[0] = '\0'; -+ int cmdline_len = 0, arg_len; - for (int j = 1; j < argc; j++) { -- strcat(saved_command_line, argv[j]); -- strncat(saved_command_line, j == argc - 1 ? "" : " ", 1); -+ 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'; - - optCon = poptGetContext("grubby", argc, argv, options, 0); - poptReadDefaultConfig(optCon, 1); --- -1.8.3.1 - diff --git a/1002-Fix-stringop-overflow-warning.patch b/1002-Fix-stringop-overflow-warning.patch deleted file mode 100644 index f7f2988..0000000 --- a/1002-Fix-stringop-overflow-warning.patch +++ /dev/null @@ -1,73 +0,0 @@ -From a38efb3c072811eb4e3bce265f1b8903a10ffad4 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Sun, 27 Sep 2020 22:40:28 +0800 -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 | 32 +++++++++++++++++--------------- - 1 file changed, 17 insertions(+), 15 deletions(-) - -diff --git a/grubby.c b/grubby.c -index 947b458..7923a7d 100644 ---- a/grubby.c -+++ b/grubby.c -@@ -5217,24 +5217,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.19.1.6.gb485710b - diff --git a/grubby-bls b/grubby-bls index 360c6e8..f5b9735 100755 --- a/grubby-bls +++ b/grubby-bls @@ -812,7 +812,9 @@ if [[ -n $kernel ]]; then opts="${opts} ${args}" fi else - opts="${args}" + opts="${opts} ${args}" + remove_args="$kernelopts" + update_args "${opts}" "${remove_args}" "" fi add_bls_fragment "${kernel}" "${title}" "${opts}" "${initrd}" \ diff --git a/grubby.spec b/grubby.spec index 0ed1620..1e9ae63 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,8 +1,6 @@ -%define anolis_release .0.1 - Name: grubby Version: 8.40 -Release: 47%{anolis_release}%{?dist} +Release: 48%{?dist} Summary: Command line tool for updating BootLoaderSpec files License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -73,21 +71,13 @@ Patch0054: 0054-Make-installkernel-to-use-kernel-install-scripts-on-.patch Patch0055: 0055-Add-usr-libexec-rpm-sort.patch Patch0056: 0056-Improve-man-page-for-info-option.patch -#Add by anolis -Patch1000: 0001-grubby-anolis-rebrand.patch -# backport from upstream -Patch1001: 1001-Fix-GCC-warnings-about-possible-string-truncations-a.patch -# port patch from fc33 -Patch1002: 1002-Fix-stringop-overflow-warning.patch -#end - BuildRequires: gcc BuildRequires: pkgconfig glib2-devel popt-devel BuildRequires: libblkid-devel git-core sed make # for make test / getopt: BuildRequires: util-linux-ng BuildRequires: rpm-devel -%ifarch aarch64 i686 x86_64 %{power64} loongarch64 +%ifarch aarch64 i686 x86_64 %{power64} BuildRequires: grub2-tools-minimal Requires: grub2-tools-minimal Requires: grub2-tools @@ -117,9 +107,6 @@ git config --unset user.email git config --unset user.name %build -%ifarch loongarch64 -export CFLAGS="%{optflags} -Wno-error=stringop-truncation -Wno-error=stringop-overflow" -%endif %set_build_flags make %{?_smp_mflags} LDFLAGS="${LDFLAGS}" @@ -182,11 +169,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog -* Tue Jan 03 2023 yangxiaoxuan - 8.40-47.0.1 -- Rebrand for Anolis OS -- Support loongarch64 -- fix build error with gcc9.2 -- Fix gcc10 build issue +* Tue Feb 21 2023 Marta Lewandowska - 8.40-48 +- Apply Marta's default args fix +- Resolves: #1900829 * Mon Oct 10 2022 Robbie Harwood - 8.40-47 - Backport fedora/rhel9 initial cmdline population -- Gitee From df34bcea3835b9b016272e1226939f9686b7f8e7 Mon Sep 17 00:00:00 2001 From: yangxiaoxuan Date: Tue, 26 Jan 2021 05:47:52 +0800 Subject: [PATCH 2/5] Rebrand for Anolis OS --- 0001-grubby-anolis-rebrand.patch | 25 +++++++++++++++++++++++++ grubby.spec | 12 +++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 0001-grubby-anolis-rebrand.patch diff --git a/0001-grubby-anolis-rebrand.patch b/0001-grubby-anolis-rebrand.patch new file mode 100644 index 0000000..672fb28 --- /dev/null +++ b/0001-grubby-anolis-rebrand.patch @@ -0,0 +1,25 @@ +From e0d8ccc74c0567fb0b319bedf9d10c5ec7def0b7 Mon Sep 17 00:00:00 2001 +From: yangxiaoxuan +Date: Tue, 26 Jan 2021 05:42:20 +0800 +Subject: [PATCH] grubby anolis rebrand + +--- + new-kernel-pkg | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/new-kernel-pkg b/new-kernel-pkg +index 0fe6caa..512ac2a 100755 +--- a/new-kernel-pkg ++++ b/new-kernel-pkg +@@ -162,6 +162,8 @@ set_title() { + title="$NAME ($version) $VERSION" + elif [ -f /etc/redhat-release ]; then + title="$(sed 's/ release.*$//' < /etc/redhat-release) ($version)" ++ elif [ -f /etc/anolis-release ]; then ++ title="$(sed 's/ release.*$//' < /etc/anolis-release) ($version)" + else + title="Red Hat Linux ($version)" + fi +-- +2.18.2 + diff --git a/grubby.spec b/grubby.spec index 1e9ae63..2deefa4 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,8 @@ +%define anolis_release .0.1 + Name: grubby Version: 8.40 -Release: 48%{?dist} +Release: 48%{anolis_release}%{?dist} Summary: Command line tool for updating BootLoaderSpec files License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -71,6 +73,11 @@ Patch0054: 0054-Make-installkernel-to-use-kernel-install-scripts-on-.patch Patch0055: 0055-Add-usr-libexec-rpm-sort.patch Patch0056: 0056-Improve-man-page-for-info-option.patch +#Add by anolis +Patch1000: 0001-grubby-anolis-rebrand.patch + +#end + BuildRequires: gcc BuildRequires: pkgconfig glib2-devel popt-devel BuildRequires: libblkid-devel git-core sed make @@ -169,6 +176,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Tue Dec 12 2023 yangxiaoxuan - 8.40-48.0.1 +- Rebrand for Anolis OS + * Tue Feb 21 2023 Marta Lewandowska - 8.40-48 - Apply Marta's default args fix - Resolves: #1900829 -- Gitee From d68cf372e6f3890027c1012eb42ff872aad671f1 Mon Sep 17 00:00:00 2001 From: liusinan Date: Fri, 27 Aug 2021 15:05:56 +0800 Subject: [PATCH 3/5] build : Support loongarch64 --- grubby.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 2deefa4..9e6cf06 100644 --- a/grubby.spec +++ b/grubby.spec @@ -84,7 +84,7 @@ BuildRequires: libblkid-devel git-core sed make # for make test / getopt: BuildRequires: util-linux-ng BuildRequires: rpm-devel -%ifarch aarch64 i686 x86_64 %{power64} +%ifarch aarch64 i686 x86_64 %{power64} loongarch64 BuildRequires: grub2-tools-minimal Requires: grub2-tools-minimal Requires: grub2-tools @@ -114,6 +114,9 @@ git config --unset user.email git config --unset user.name %build +%ifarch loongarch64 +export CFLAGS="%{optflags} -Wno-error=stringop-truncation -Wno-error=stringop-overflow" +%endif %set_build_flags make %{?_smp_mflags} LDFLAGS="${LDFLAGS}" @@ -178,6 +181,7 @@ current boot environment. %changelog * Tue Dec 12 2023 yangxiaoxuan - 8.40-48.0.1 - Rebrand for Anolis OS +- Support loongarch64 * Tue Feb 21 2023 Marta Lewandowska - 8.40-48 - Apply Marta's default args fix -- Gitee From 133466d057d8628270adcae849624457df64a47b Mon Sep 17 00:00:00 2001 From: Chunmei Xu Date: Fri, 29 May 2020 14:22:42 +0800 Subject: [PATCH 4/5] [build][gcc9] fix build error with >=gcc9.2 Signed-off-by: weitao zhou --- ...-about-possible-string-truncations-a.patch | 107 ++++++++++++++++++ grubby.spec | 5 +- 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 1001-Fix-GCC-warnings-about-possible-string-truncations-a.patch diff --git a/1001-Fix-GCC-warnings-about-possible-string-truncations-a.patch b/1001-Fix-GCC-warnings-about-possible-string-truncations-a.patch new file mode 100644 index 0000000..db16955 --- /dev/null +++ b/1001-Fix-GCC-warnings-about-possible-string-truncations-a.patch @@ -0,0 +1,107 @@ +From 9a2fc457659cc2baee7d13ed6b0f8c864ae605d9 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Tue, 5 Feb 2019 17:29:11 +0100 +Subject: [PATCH] Fix GCC warnings about possible string truncations and buffer + overflows + +Building with -Werror=stringop-truncation and -Werror=stringop-overflow +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: Javier Martinez Canillas +--- + grubby.c | 38 ++++++++++++++++++++++++++++++-------- + 1 file changed, 30 insertions(+), 8 deletions(-) + +diff --git a/grubby.c b/grubby.c +index 396041a..947b458 100644 +--- a/grubby.c ++++ b/grubby.c +@@ -479,20 +479,28 @@ char *grub2ExtractTitle(struct singleLine *line) + snprintf(result, resultMaxSize, "%s", ++current); + + i++; ++ int result_len = 0; + for (; i < line->numElements; ++i) { + current = line->elements[i].item; + current_len = strlen(current); + current_indent = line->elements[i].indent; + current_indent_len = strlen(current_indent); + +- strncat(result, current_indent, current_indent_len); ++ memcpy(result + result_len, current_indent, current_indent_len); ++ result_len += current_indent_len; ++ + if (current[current_len - 1] != quote_char) { +- strncat(result, current, current_len); ++ memcpy(result + result_len, current_indent, ++ current_indent_len); ++ result_len += current_len; + } else { +- strncat(result, current, current_len - 1); ++ memcpy(result + result_len, current_indent, ++ current_indent_len); ++ result_len += (current_len - 1); + break; + } + } ++ result[result_len] = '\0'; + return result; + } + +@@ -1437,6 +1445,7 @@ static struct grubConfig *readConfig(const char *inName, + extras = malloc(len + 1); + *extras = '\0'; + ++ int buf_len = 0; + /* get title. */ + for (int i = 0; i < line->numElements; i++) { + if (!strcmp +@@ -1453,13 +1462,18 @@ static struct grubConfig *readConfig(const char *inName, + + len = strlen(title); + if (title[len - 1] == quote_char) { +- strncat(buf, title, len - 1); ++ memcpy(buf + buf_len, title, len - 1); ++ buf_len += (len - 1); + break; + } else { +- strcat(buf, title); +- strcat(buf, line->elements[i].indent); ++ memcpy(buf + buf_len, title, len); ++ buf_len += len; ++ len = strlen(line->elements[i].indent); ++ memcpy(buf + buf_len, line->elements[i].indent, len); ++ buf_len += len; + } + } ++ buf[buf_len] = '\0'; + + /* get extras */ + int count = 0; +@@ -5209,10 +5223,18 @@ int main(int argc, const char **argv) + exit(1); + } + saved_command_line[0] = '\0'; ++ int cmdline_len = 0, arg_len; + for (int j = 1; j < argc; j++) { +- strcat(saved_command_line, argv[j]); +- strncat(saved_command_line, j == argc - 1 ? "" : " ", 1); ++ 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'; + + optCon = poptGetContext("grubby", argc, argv, options, 0); + poptReadDefaultConfig(optCon, 1); +-- +1.8.3.1 + diff --git a/grubby.spec b/grubby.spec index 9e6cf06..2383d7c 100644 --- a/grubby.spec +++ b/grubby.spec @@ -76,8 +76,10 @@ Patch0056: 0056-Improve-man-page-for-info-option.patch #Add by anolis Patch1000: 0001-grubby-anolis-rebrand.patch -#end +# backport from upstream +Patch1001: 1001-Fix-GCC-warnings-about-possible-string-truncations-a.patch +#end BuildRequires: gcc BuildRequires: pkgconfig glib2-devel popt-devel BuildRequires: libblkid-devel git-core sed make @@ -182,6 +184,7 @@ current boot environment. * Tue Dec 12 2023 yangxiaoxuan - 8.40-48.0.1 - Rebrand for Anolis OS - Support loongarch64 +- fix build error with gcc9.2 * Tue Feb 21 2023 Marta Lewandowska - 8.40-48 - Apply Marta's default args fix -- Gitee From b10393ddf939d2968db61f904d5e3c72e6bb283a Mon Sep 17 00:00:00 2001 From: Liwei Ge Date: Sun, 27 Sep 2020 22:47:11 +0800 Subject: [PATCH 5/5] Fix gcc10 build issue for better compatibility on both gcc8&gcc10 this change has given better compatible with both gcc8 and gcc10 toolchain, should be maintained util upstream fixes Signed-off-by: weitao zhou --- 1002-Fix-stringop-overflow-warning.patch | 73 ++++++++++++++++++++++++ grubby.spec | 6 +- 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 1002-Fix-stringop-overflow-warning.patch diff --git a/1002-Fix-stringop-overflow-warning.patch b/1002-Fix-stringop-overflow-warning.patch new file mode 100644 index 0000000..f7f2988 --- /dev/null +++ b/1002-Fix-stringop-overflow-warning.patch @@ -0,0 +1,73 @@ +From a38efb3c072811eb4e3bce265f1b8903a10ffad4 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Sun, 27 Sep 2020 22:40:28 +0800 +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 | 32 +++++++++++++++++--------------- + 1 file changed, 17 insertions(+), 15 deletions(-) + +diff --git a/grubby.c b/grubby.c +index 947b458..7923a7d 100644 +--- a/grubby.c ++++ b/grubby.c +@@ -5217,24 +5217,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.19.1.6.gb485710b + diff --git a/grubby.spec b/grubby.spec index 2383d7c..e82ceb8 100644 --- a/grubby.spec +++ b/grubby.spec @@ -75,11 +75,12 @@ Patch0056: 0056-Improve-man-page-for-info-option.patch #Add by anolis Patch1000: 0001-grubby-anolis-rebrand.patch - # backport from upstream Patch1001: 1001-Fix-GCC-warnings-about-possible-string-truncations-a.patch - +# port patch from fc33 +Patch1002: 1002-Fix-stringop-overflow-warning.patch #end + BuildRequires: gcc BuildRequires: pkgconfig glib2-devel popt-devel BuildRequires: libblkid-devel git-core sed make @@ -185,6 +186,7 @@ current boot environment. - Rebrand for Anolis OS - Support loongarch64 - fix build error with gcc9.2 +- Fix gcc10 build issue * Tue Feb 21 2023 Marta Lewandowska - 8.40-48 - Apply Marta's default args fix -- Gitee