Package: acpitool
Version: 0.5.1-3
Tags: patch
While parsing /proc/acpi/wakeup, src/acpitool.cpp assumes that lines are
maximum 39 char long (40 including the terminating NUL character at the
end of C strings).
Since I have a line in /proc/acpi/wakeup that is exactly 40 char long,
the tool doesn't work (it hangs up when it hits that line, consuming
100% CPU forever).
The attached patch changes this behavior to assume maximum 79 char long
lines by increasing the buffer size to 80.
diff -ur acpitool-0.5.1/debian/patches/wakeup.patch acpitool-0.5.1.patched/debian/patches/wakeup.patch
--- acpitool-0.5.1/debian/patches/wakeup.patch 2014-09-26 10:20:52.000000000 +0200
+++ acpitool-0.5.1.patched/debian/patches/wakeup.patch 2014-09-26 10:16:07.163701983 +0200
@@ -13,15 +13,44 @@
have a device called "LID" which is 3 characters long.
Instead of using a fixed size for the device we split the line
on the first tab (\t) and use the first part.
+
+ * The length of lines in /proc/acpi/wakeup can have more than 39
+ characters, I have one with exactly 40. So let's increase the
+ reading buffer to 80 characters.
---
src/acpitool.cpp | 23 +++++++++++------------
1 files changed, 11 insertions(+), 12 deletions(-)
-diff --git a/src/acpitool.cpp b/src/acpitool.cpp
-index 2a610a5..71e01d7 100644
---- a/src/acpitool.cpp
-+++ b/src/acpitool.cpp
-@@ -460,16 +460,14 @@ int Show_WakeUp_Devices(int verbose)
+Index: acpitool-0.5.1/src/acpitool.cpp
+===================================================================
+--- acpitool-0.5.1.orig/src/acpitool.cpp
++++ acpitool-0.5.1/src/acpitool.cpp
+@@ -416,7 +416,7 @@ int Do_Fan_Info(int verbose)
+ int Show_WakeUp_Devices(int verbose)
+ {
+ ifstream file_in;
+- char *filename, str[40];
++ char *filename, str[80];
+
+ filename = "/proc/acpi/wakeup";
+
+@@ -437,13 +437,13 @@ int Show_WakeUp_Devices(int verbose)
+ }
+ else
+ {
+- file_in.getline(str, 40); // first line are just headers //
++ file_in.getline(str, 80); // first line are just headers //
+ cout<<" "<<str<<endl;
+ cout<<" ---------------------------------------"<<endl;
+ int t = 1;
+ while(!file_in.eof())
+ {
+- file_in.getline(str, 40);
++ file_in.getline(str, 80);
+ if (strlen(str)!=0) // avoid printing last empty line //
+ {
+ cout<<" "<<t<<". "<<str<<endl;
+@@ -459,16 +459,14 @@ int Show_WakeUp_Devices(int verbose)
int Toggle_WakeUp_Device(const int Device, int verbose)
{
@@ -43,7 +72,7 @@
{
if(!verbose)
{
-@@ -484,14 +482,15 @@ int Toggle_WakeUp_Device(const int Device, int verbose)
+@@ -483,14 +481,15 @@ int Toggle_WakeUp_Device(const int Devic
}
}
@@ -64,7 +93,3 @@
index++;
}
}
---
-1.7.5.4
-
-