Login
Log in using an SSO provider:
Fedora Account System
Red Hat Associate
Red Hat Customer
Login using a Red Hat Bugzilla account
Forgot Password
Create an Account
Red Hat Bugzilla – Attachment 1873729 Details for
Bug 2026563
acpitool segfaults on Get_Kernel_Version
Home
New
Search
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh90 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
[?]
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Replace char by std::string to avoid buffer overflows for long headers
0001-Replace-CString-by-StdString.patch (text/plain), 5.63 KB, created by
bugzillamail
on 2022-04-20 08:01:26 UTC
(
hide
)
Description:
Replace char by std::string to avoid buffer overflows for long headers
Filename:
MIME Type:
Creator:
bugzillamail
Created:
2022-04-20 08:01:26 UTC
Size:
5.63 KB
patch
obsolete
>From 189de30a2cbcf2af6641a02e74d3fcb4fdce869a Mon Sep 17 00:00:00 2001 >From: Claudius Zingerli <gitmail@zeuz.ch> >Date: Wed, 20 Apr 2022 09:51:29 +0200 >Subject: [PATCH] Bump version > >--- > acpitool.spec | 7 ++- > stringbuffer.patch | 141 +++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 147 insertions(+), 1 deletion(-) > create mode 100644 stringbuffer.patch > >diff --git a/acpitool.spec b/acpitool.spec >index 0753434..ddf64b2 100644 >--- a/acpitool.spec >+++ b/acpitool.spec >@@ -1,7 +1,7 @@ > Summary: Command line ACPI client > Name: acpitool > Version: 0.5.1 >-Release: 28%{?dist} >+Release: 29%{?dist} > License: GPLv2+ > URL: https://sourceforge.net/projects/acpitool/ > BuildRequires: gcc-c++ >@@ -16,6 +16,7 @@ Patch4: var-line.patch > Patch5: typos.patch > Patch6: cleanup.patch > Patch7: cache-size.patch >+Patch8: stringbuffer.patch > > %description > AcpiTool is a Linux ACPI client. It's a small command line application, >@@ -36,6 +37,7 @@ toggle fan on/off, and more. > %patch5 -p1 -b .typos > %patch6 -p1 -b .cleanup > %patch7 -p1 -b .cache-size >+%patch8 -p1 -b .stringbuffer > > %build > %configure >@@ -51,6 +53,9 @@ make install DESTDIR=$RPM_BUILD_ROOT > %{_mandir}/man1/acpitool* > > %changelog >+* Wed Apr 20 2022 Claudius Zingerli <gitmail@zeuz.ch> - 0.5.1-29 >+- Fix buffer overflow with long kernel names >+ > * Wed Jan 19 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.5.1-28 > - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild > >diff --git a/stringbuffer.patch b/stringbuffer.patch >new file mode 100644 >index 0000000..3bad265 >--- /dev/null >+++ b/stringbuffer.patch >@@ -0,0 +1,141 @@ >+From b53201cf2ac8d58c7bd660f848e0a2d7794a7ed9 Mon Sep 17 00:00:00 2001 >+From: Claudius Zingerli <gitmail@zeuz.ch> >+Date: Wed, 20 Apr 2022 09:39:23 +0200 >+Subject: [PATCH 2/2] Replace c string by cpp strings >+ >+--- >+ src/acpitool.cpp | 47 +++++++++++++++++++++++++++-------------------- >+ 1 file changed, 27 insertions(+), 20 deletions(-) >+ >+diff --git a/src/acpitool.cpp b/src/acpitool.cpp >+index f698733..4a70c9a 100644 >+--- a/src/acpitool.cpp >++++ b/src/acpitool.cpp >+@@ -1,7 +1,7 @@ >+ /*---------------------------------------------------------------------------*/ >+ /* Program to get/set some ACPI settings */ >+ /* Author : David Leemans - http://freeunix.dyndns.org:8000/ */ >+-/* Last update : 16-10-2008 */ >++/* Last update : 2022-04-20 */ >+ /*---------------------------------------------------------------------------*/ >+ /* */ >+ /* acpitool.cpp */ >+@@ -61,11 +61,11 @@ int Use_Sys = 0, Use_Proc = 0; >+ >+ /*----------------------------------------------------------------------------------------------------------------------------*/ >+ >+-int Has_ACPI(char *c) >++ >++int Has_ACPI(string &version) >+ { >+ ifstream file_in, file2_in; >+ char const *filename, *filename2; >+- char str[50]; >+ >+ filename = "/proc/acpi/info"; >+ filename2 = "/sys/module/acpi/parameters/acpica_version"; >+@@ -77,16 +77,19 @@ int Has_ACPI(char *c) >+ { >+ cout<<" Could not open any of these files : "<<filename<<", "<<filename2<<endl; >+ cout<<" Make sure your kernel has ACPI support enabled."<<endl; >+- strcpy(c, "n.a"); >++ version = "n.a"; >+ return 0; >+ } >+ else >+ { >+ if(file_in) >+ { >+- file_in.getline(str, 50); >++ getline(file_in, version); >+ file_in.close(); >+- strncpy(c, str+25,8); >++ if(version.size() > 25) >++ { >++ version.erase(0, 25); >++ } >+ Use_Proc = 1; >+ >+ // cout<<" Got ACPI version from: "<<filename<<endl; // >+@@ -95,9 +98,12 @@ int Has_ACPI(char *c) >+ } >+ if(file2_in) >+ { >+- file2_in.getline(str, 50); >++ getline(file2_in, version); >+ file2_in.close(); >+- strncpy(c, str,8); >++ if(version.size() > 8) >++ { >++ version.erase(8, string::npos); >++ } >+ Use_Sys = 1; >+ >+ // cout<<" Got ACPI version from: "<<filename2<<endl; // >+@@ -109,6 +115,13 @@ int Has_ACPI(char *c) >+ } >+ >+ >++int Has_ACPI(char *c) >++{ >++ std::string version; >++ int rc = Has_ACPI(version); >++ strcpy(c, version.c_str()); >++ return rc; >++} >+ >+ >+ int Print_ACPI_Info(int show_ac, int show_therm, int show_trip, int show_fan, int show_batteries, int show_empty, int show_version, int show_cpu, int show_wake, int e_set, int info_level, int verbose) >+@@ -136,11 +149,10 @@ int Print_ACPI_Info(int show_ac, int show_therm, int show_trip, int show_fan, in >+ >+ >+ >+-int Get_Kernel_Version(char *c, int verbose) >++int Get_Kernel_Version(string &version, int verbose) >+ { >+ ifstream file_in; >+ char const *filename; >+- char str[20]; >+ >+ filename = "/proc/sys/kernel/osrelease"; >+ >+@@ -149,7 +161,7 @@ int Get_Kernel_Version(char *c, int verbose) >+ { >+ if(!verbose) >+ { >+- strcpy(c, "<n.a>"); >++ version = "<n.a>"; >+ return 0; >+ } >+ else >+@@ -158,23 +170,18 @@ int Get_Kernel_Version(char *c, int verbose) >+ return -1; >+ } >+ } >+- >+- file_in.getline(str, 16); >++ >++ getline(file_in, version); >+ file_in.close(); >+- >+- strcpy(c, str); >+- >++ >+ return 0; >+ } >+ >+ >+ int Do_SysVersion_Info(int verbose) >+ { >+- char Acpi_Version[10], Kernel_Version[15]; >++ string Kernel_Version, Acpi_Version; >+ >+- memset(Acpi_Version, '\0', 10); >+- memset(Kernel_Version, '\0', 15); >+- >+ Get_Kernel_Version(Kernel_Version, verbose); >+ Has_ACPI(Acpi_Version); >+ >+-- >+2.35.1 >+ >-- >2.35.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 2026563
:
1843583
|
1843588
| 1873729