1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
Fixes buffer overflows and --as-needed issues
https://bugs.gentoo.org/show_bug.cgi?id=338936
Patch written by Kevin Pyle <gentoo.8eaf7cd8e5128d8191fe@spamgourmet.com>
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-AM_CPPFLAGS = @CPPFLAGS@ @INTERLACE@ \
+AM_CPPFLAGS = @INTERLACE@ \
-DGLOBAL_BB=\"$(datadir)/bbtools/bbacpi.bb\" \
-DGLOBAL_NOBB=\"$(datadir)/bbtools/bbacpi.nobb\" \
-DGLOBAL_DATA=\"$(datadir)/bbtools\"
--- a/bbacpi.cc
+++ b/bbacpi.cc
@@ -167,7 +167,7 @@ bool CheckLoad::checkbatteryfile (char* name, char* device)
if (ret = (fp = fopen(name, "r"))) {
char buffer[100];
char present[20];
- fgets(buffer,128,fp);
+ fgets(buffer, sizeof(buffer),fp);
sscanf(buffer,"present: %s", present);
if (strncmp(present, "yes", 3) != 0) {
fprintf(stderr, "Device %s not present.\n", device);
@@ -195,7 +195,7 @@ void CheckLoad::ReadStaticInfo()
{
/* Read data in any order */
found = 0;
- while (found < 11 && (fgets(buffer, 63, fp) != NULL)) {
+ while (found < 11 && (fgets(buffer, sizeof(buffer), fp) != NULL)) {
/* Present */
if (strncmp(buffer, "present:", 7) == 0
|| strncmp(buffer, "Present:", 7) == 0) {
@@ -277,7 +277,7 @@ void CheckLoad::ReadStaticInfo()
{
/* Read data in any order */
found = 0;
- while (found < 11 && (fgets(buffer, 63, fp) != NULL)) {
+ while (found < 11 && (fgets(buffer, sizeof(buffer), fp) != NULL)) {
/* Present */
if (strncmp(buffer, "present:", 7) == 0
|| strncmp(buffer, "Present:", 7) == 0) {
@@ -361,7 +361,7 @@ void CheckLoad::ReadStaticInfo()
if ((fp = fopen(names.temptrip, "r")))
{
found = 0;
- while (found < 2 && (fgets(buffer,128,fp) != NULL)) {
+ while (found < 2 && (fgets(buffer, sizeof(buffer),fp) != NULL)) {
/* Critical */
if (strncmp(buffer, "critical", 8) == 0
|| strncmp(buffer, "Critical", 8) == 0) {
@@ -425,7 +425,7 @@ void CheckLoad::Reconfigure()
if (file_status.st_mtime != last_mtime)
{
found = 0;
- while (found < 4 && (fgets(buffer, 63, fp) != NULL)) {
+ while (found < 4 && (fgets(buffer, sizeof(buffer), fp) != NULL)) {
/* Charging state */
if (strncmp(buffer, "charging state:", 15) == 0
|| strncmp(buffer, "Charging State:", 15) == 0) {
@@ -463,7 +463,7 @@ void CheckLoad::Reconfigure()
if (file_status.st_mtime != last_mtime)
{
found = 0;
- while (found < 4 && (fgets(buffer, 63, fp) != NULL)) {
+ while (found < 4 && (fgets(buffer, sizeof(buffer), fp) != NULL)) {
/* Charging state */
if (strncmp(buffer, "charging state:", 15) == 0
|| strncmp(buffer, "Charging State:", 15) == 0) {
@@ -497,7 +497,7 @@ void CheckLoad::Reconfigure()
if ((fp = fopen(names.adapter, "r")))
{
found = 0;
- while (found < 1 && (fgets(buffer, 63,fp) != NULL)) {
+ while (found < 1 && (fgets(buffer, sizeof(buffer),fp) != NULL)) {
if (strncmp(buffer, "state:", 6) == 0
|| strncmp(buffer, "State:", 6) == 0) {
sscanf(buffer+offset,"%s", adapter.state);
@@ -511,7 +511,7 @@ void CheckLoad::Reconfigure()
if ((fp = fopen(names.temperature, "r")))
{
found = 0;
- while (found < 1 && (fgets(buffer, 63,fp) != NULL)) {
+ while (found < 1 && (fgets(buffer, sizeof(buffer),fp) != NULL)) {
if (strncmp(buffer, "temperature:", 12) == 0
|| strncmp(buffer, "Temperature:", 12) == 0) {
sscanf(buffer+offset,"%u", &temperature.celcius);
--- a/configure.in
+++ b/configure.in
@@ -89,12 +89,12 @@ AC_PATH_XTRA
CFLAGS="$CFLAGS $X_CFLAGS"
CXXFLAGS="$CXXFLAGS $X_CFLAGS"
-LDFLAGS="$LDFLAGS $X_LIBS $X_PRE_LIBS"
+LIBS="$LIBS $X_LIBS $X_PRE_LIBS"
dnl Checks for X libraries.
-AC_CHECK_LIB(X11, XOpenDisplay, LDFLAGS="$LDFLAGS -lX11",
+AC_CHECK_LIB(X11, XOpenDisplay,,
AC_MSG_ERROR(XOpenDisplay not found in -lX11))
-LDFLAGS="$LDFLAGS $X_EXTRA_LIBS"
+LIBS="$LIBS $X_EXTRA_LIBS"
dnl Check for Imlib
AC_MSG_CHECKING([for Imlib])
|