summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2013-08-15 21:47:24 +0000
committerMike Frysinger <vapier@gentoo.org>2013-08-15 21:47:24 +0000
commit438eff3ca0ca6e595273b69afc64b8e7bb8ddfd8 (patch)
treef78a282eda90216d43e1f9e0efa08363e6b9ec93 /sys-power/nvclock/files
parentFix file collisions wrt bug #481106. (diff)
downloadgentoo-2-438eff3ca0ca6e595273b69afc64b8e7bb8ddfd8.tar.gz
gentoo-2-438eff3ca0ca6e595273b69afc64b8e7bb8ddfd8.tar.bz2
gentoo-2-438eff3ca0ca6e595273b69afc64b8e7bb8ddfd8.zip
Fix gtk linkage against X libs. Respect $AR settings. Fix .desktop warnings. Fix buffers overflows in random messages #364667 by Diego Elio Pettenò.
(Portage version: 2.2.0/cvs/Linux x86_64, signed Manifest commit with key FB7C4156)
Diffstat (limited to 'sys-power/nvclock/files')
-rw-r--r--sys-power/nvclock/files/nvclock-0.8_p20110102-buffers.patch202
-rw-r--r--sys-power/nvclock/files/nvclock-0.8_p20110102-desktop.patch18
-rw-r--r--sys-power/nvclock/files/nvclock-0.8_p20110102-r1-make.patch94
-rw-r--r--sys-power/nvclock/files/nvclock-0.8_p20110102-usleep.patch6
4 files changed, 319 insertions, 1 deletions
diff --git a/sys-power/nvclock/files/nvclock-0.8_p20110102-buffers.patch b/sys-power/nvclock/files/nvclock-0.8_p20110102-buffers.patch
new file mode 100644
index 000000000000..f64cb9b8456d
--- /dev/null
+++ b/sys-power/nvclock/files/nvclock-0.8_p20110102-buffers.patch
@@ -0,0 +1,202 @@
+https://bugs.gentoo.org/364667
+
+clean up random buffer overflows in the code
+
+--- a/src/backend/back_linux.c
++++ b/src/backend/back_linux.c
+@@ -42,7 +42,9 @@ static int probe_devices();
+ static int check_driver()
+ {
+ FILE *proc;
+- char buffer[80];
++ char *buffer = NULL;
++ size_t len;
++ int ret = 0;
+
+ proc = fopen("/proc/modules", "r");
+
+@@ -50,9 +52,9 @@ static int check_driver()
+ if(proc == NULL)
+ return 0;
+
+- while(fgets(buffer, 80, proc) != NULL)
++ while(getline(&buffer, &len, proc) != -1)
+ {
+- char name[80];
++ char name[100];
+ int size;
+ int used;
+
+@@ -64,26 +66,23 @@ static int check_driver()
+ {
+ if(strcmp(name, "NVdriver") == 0)
+ {
+- fclose(proc);
+ if(used)
+- return 1;
+-
+- return 0;
++ ret = 1;
++ break;
+ }
+
+ if(strcmp(name, "nvidia") == 0)
+ {
+- fclose(proc);
+ if(used)
+- return 2;
+-
+- return 0;
++ ret = 2;
++ break;
+ }
+ }
+ }
++ free(buffer);
+ fclose(proc);
+
+- return 0;
++ return ret;
+ }
+
+ int init_nvclock()
+@@ -114,7 +113,8 @@ static int probe_devices()
+ {
+ int dev, irq, reg_addr, i=0;
+ unsigned short devbusfn;
+- char buf[256];
++ char *buf = NULL;
++ size_t len;
+ FILE *proc;
+
+ proc = fopen("/proc/bus/pci/devices", "r");
+@@ -124,7 +124,7 @@ static int probe_devices()
+ return 0;
+ }
+
+- while(fgets(buf, sizeof(buf)-1, proc))
++ while(getline(&buf, &len, proc) != -1)
+ {
+ if(sscanf(buf,"%hx %x %x %x",&devbusfn, &dev, &irq, &reg_addr) != 4) continue;
+
+@@ -181,6 +181,7 @@ static int probe_devices()
+ i++;
+ }
+ }
++ free(buf);
+ fclose(proc);
+
+ if(i==0)
+--- a/src/backend/config.c
++++ b/src/backend/config.c
+@@ -286,8 +286,9 @@ int open_config()
+ {
+ if(mkdir(nvclock.path, 0755))
+ {
+- char buf[80];
+- sprintf(buf, "Can't create '%s'. Do you have sufficient permissions?\n", nvclock.path);
++ char buf[1024];
++ snprintf(buf, sizeof(buf), "Can't create path (do you have sufficient permissions?): %s", nvclock.path);
++ buf[sizeof(buf) - 1] = '\0';
+ set_error_str(buf);
+ return 0;
+ }
+@@ -297,8 +298,9 @@ int open_config()
+ /* Check if .nvclock really is a directory. For some users it was a file and this led to a segfault. */
+ if(!S_ISDIR(stat_buf.st_mode))
+ {
+- char buf[80];
+- sprintf(buf, "Can't open '%s'. Is it really a directory?\n", nvclock.path);
++ char buf[1024];
++ snprintf(buf, sizeof(buf), "Can't open path (Is it really a directory?): %s", nvclock.path);
++ buf[sizeof(buf) - 1] = '\0';
+ set_error_str(buf);
+ return 0;
+ }
+--- a/src/backend/error.c
++++ b/src/backend/error.c
+@@ -41,23 +41,19 @@ void set_error_str(const char *str)
+ }
+
+
+-char *get_error(char *buf, int size)
++const char *get_error(void)
+ {
+ switch(nvclock.nv_errno)
+ {
+ case NV_ERR_NO_DEVICES_FOUND:
+- strcpy(buf, "No nvidia cards found in your system!");
+- break;
++ return "No nvidia cards found in your system!";
+ case NV_ERR_NO_DRIVERS_FOUND:
+- strcpy(buf, "You don't have enough permissions to run NVClock! Retry as root or install the Nvidia drivers.");
+- break;
++ return "You don't have enough permissions to run NVClock! Retry as root or install the Nvidia drivers.";
+ case NV_ERR_NOT_ENOUGH_PERMISSIONS:
+- strcpy(buf, "You don't have enough permissions to run NVClock! Retry as root.");
+- break;
++ return "You don't have enough permissions to run NVClock! Retry as root.";
+ case NV_ERR_OTHER:
+- strcpy(buf, nvclock.nv_err_str);
+- break;
++ return nvclock.nv_err_str;
+ }
+
+- return buf;
++ return "unknown";
+ }
+--- a/src/backend/nvclock.h
++++ b/src/backend/nvclock.h
+@@ -335,7 +335,7 @@ cfg_entry* lookup_entry(cfg_entry **cfg, char *section, char *name);
+ void destroy(cfg_entry **cfg);
+
+ /* error handling */
+-char *get_error(char *buf, int size);
++const char *get_error(void);
+ void set_error(int code);
+ void set_error_str(const char *err);
+
+--- a/src/gtk/main.c
++++ b/src/gtk/main.c
+@@ -264,8 +264,7 @@ int main (int argc, char *argv[])
+ */
+ if(!init_nvclock())
+ {
+- char buf[80];
+- GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", get_error(buf, 80));
++ GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", get_error());
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ g_signal_connect_swapped(GTK_OBJECT(dialog), "response", G_CALLBACK(gtk_widget_destroy), GTK_OBJECT(dialog));
+ gtk_widget_destroy(dialog);
+--- a/src/nvclock.c
++++ b/src/nvclock.c
+@@ -604,8 +604,7 @@ int main(int argc, char *argv[])
+
+ if(!init_nvclock())
+ {
+- char buf[80];
+- fprintf(stderr, "Error: %s\n", get_error(buf, 80));
++ fprintf(stderr, "Error: %s\n", get_error());
+ return 0;
+ }
+
+@@ -851,8 +850,7 @@ int main(int argc, char *argv[])
+ {
+ if(!set_card(i))
+ {
+- char buf[80];
+- fprintf(stderr, "Error: %s\n", get_error(buf, 80));
++ fprintf(stderr, "Error: %s\n", get_error());
+ return 0;
+ }
+
+@@ -887,8 +885,7 @@ int main(int argc, char *argv[])
+ /* set the card object to the requested card */
+ if(!set_card(card_number))
+ {
+- char buf[80];
+- fprintf(stderr, "Error: %s\n", get_error(buf, 80));
++ fprintf(stderr, "Error: %s\n", get_error());
+ return 0;
+ }
+
diff --git a/sys-power/nvclock/files/nvclock-0.8_p20110102-desktop.patch b/sys-power/nvclock/files/nvclock-0.8_p20110102-desktop.patch
new file mode 100644
index 000000000000..034208ff817a
--- /dev/null
+++ b/sys-power/nvclock/files/nvclock-0.8_p20110102-desktop.patch
@@ -0,0 +1,18 @@
+fix qa warning:
+
+/usr/share/applications/nvclock.desktop: error: (will be fatal in the future):
+value "nvclock.png" for key "Icon" in group "Desktop Entry" is an icon name
+with an extension, but there should be no extension as described in the Icon
+Theme Specification if the value is not an absolute path
+
+--- a/nvclock.desktop
++++ b/nvclock.desktop
+@@ -3,7 +3,7 @@ Encoding=UTF-8
+ Name=NVCLOCK
+ Comment=Overclock and Monitor NVIDIA cards
+ Exec=nvclock_gtk
+-Icon=nvclock.png
++Icon=nvclock
+ Terminal=false
+ Type=Application
+ Categories=System;
diff --git a/sys-power/nvclock/files/nvclock-0.8_p20110102-r1-make.patch b/sys-power/nvclock/files/nvclock-0.8_p20110102-r1-make.patch
new file mode 100644
index 000000000000..e45e2a6aa341
--- /dev/null
+++ b/sys-power/nvclock/files/nvclock-0.8_p20110102-r1-make.patch
@@ -0,0 +1,94 @@
+- Fix building with --as-needed
+- Fix parallel make by defining two new targets
+- Fix one spelling error
+- Respect CFLAGS, LDFLAGS
+- Link GTK frontend against -lX11 since it uses XOpenDisplay all the time
+
+--- a/configure.in
++++ b/configure.in
+@@ -141,7 +141,7 @@
+ if [test "$HAVE_NVCONTROL" = "yes"]; then
+ echo "- NV-CONTROL support enabled"
+ else
+- echo "- NV-CONROL support disabled"
++ echo "- NV-CONTROL support disabled"
+ fi
+ if [test "$HAVE_GTK2" = "yes"]; then
+ echo "- GTK2 GUI enabled"
+--- a/src/Makefile.in
++++ b/src/Makefile.in
+@@ -16,7 +16,7 @@
+ ifeq ($(HAVE_NVCONTROL), yes)
+ DEPS=$(libbackend) $(libnvcontrol)
+ INCLUDES=@X11_CFLAGS@ -I./backend -I./nvcontrol -I..
+- LIBS=@X11_LIBS@ -L./backend -lbackend -L./nvcontrol -lnvcontrol
++ LIBS=-L./backend -lbackend -L./nvcontrol -lnvcontrol @X11_LIBS@
+ else
+ DEPS=$(libbackend)
+ INCLUDES=-I./backend -I./nvcontrol -I..
+@@ -30,12 +30,17 @@
+
+ all: all-recursive nvclock smartdimmer
+
++$(libbackend):
++ $(MAKE) -C backend
++
++$(libnvcontrol):
++ $(MAKE) -C nvcontrol
+
+ nvclock: $(DEPS) $(LIB) nvclock.c
+- $(CC) $(CFLAGS) -o nvclock $(nvclock_SOURCES) $(INCLUDES) $(LIBS)
++ $(CC) $(CFLAGS) $(LDFLAGS) -o nvclock $(nvclock_SOURCES) $(INCLUDES) $(LIBS)
+
+ smartdimmer: $(DEPS) $(LIB) smartdimmer.c
+- $(CC) $(CFLAGS) -o smartdimmer $(smartdimmer_SOURCES) $(INCLUDES) $(LIBS)
++ $(CC) $(CFLAGS) $(LDFLAGS) -o smartdimmer $(smartdimmer_SOURCES) $(INCLUDES) $(LIBS)
+
+
+ clean: clean-recursive clean-app
+--- a/src/gtk/Makefile.in
++++ b/src/gtk/Makefile.in
+@@ -27,6 +27,7 @@
+ LIBS=@GTK_LIBS@ -L../backend -lbackend
+ OBJECTS=banner.o hw.o main.o settings.o
+ endif
++LIBS += -lX11
+
+
+ .PHONY: clean distclean install
+@@ -33,7 +33,7 @@
+ all: $(PROGRAM)
+
+ nvclock_gtk: $(DEPS) $(OBJECTS)
+- $(CC) $(CFLAGS) -o nvclock_gtk $(OBJECTS) $(libbackend) $(LIBS)
++ $(CC) $(CFLAGS) $(LDFLAGS) -o nvclock_gtk $(OBJECTS) $(libbackend) $(LIBS)
+
+ clean:
+ rm -f nvclock_gtk *.core *.o *.exe
+--- a/src/qt/Makefile.in
++++ b/src/qt/Makefile.in
+@@ -31,7 +31,7 @@
+ all: $(PROGRAM)
+
+ nvclock_qt: $(DEPS) qt_nvclock.moc qt_xfree.moc $(OBJECTS)
+- $(CXX) $(CXXFLAGS) -o nvclock_qt $(CXXFLAGS) $(OBJECTS) $(LIBS)
++ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o nvclock_qt $(OBJECTS) $(LIBS)
+
+ clean:
+ rm -f nvclock_qt *.core *.moc *.o
+--- a/src/backend/Makefile.in
++++ b/src/backend/Makefile.in
+@@ -1,11 +1,11 @@
+-CC=@CC@ -O0
++CC=@CC@
+ AR=ar
+ RANLIB=@RANLIB@
+
+ system=@system@
+ HAVE_NVCONTROL=@HAVE_NVCONTROL@
+ OBJECTS=backend.o bios.o config.o error.o nv30.o nv40.o nv50.o info.o overclock.o utils.o i2c.o xf86i2c.o adt7473.o f75375.o lm99.o w83781d.o w83l785r.o libc_wrapper.o
+-CFLAGS=@X11_CFLAGS@ -I../.. -I../nvcontrol
++CFLAGS=@CFLAGS@ @X11_CFLAGS@ -I../.. -I../nvcontrol
+
+ ifeq ($(system), FreeBSD)
+ OBJECTS+=back_bsd.o
diff --git a/sys-power/nvclock/files/nvclock-0.8_p20110102-usleep.patch b/sys-power/nvclock/files/nvclock-0.8_p20110102-usleep.patch
index 4391ee79ff83..93c3f288864b 100644
--- a/sys-power/nvclock/files/nvclock-0.8_p20110102-usleep.patch
+++ b/sys-power/nvclock/files/nvclock-0.8_p20110102-usleep.patch
@@ -1,7 +1,11 @@
+fix warning:
+libc_wrapper.c:54: warning: implicit declaration of function usleep
+
--- a/src/backend/libc_wrapper.c
+++ b/src/backend/libc_wrapper.c
-@@ -27,6 +27,7 @@
+@@ -27,6 +27,8 @@
++#define _BSD_SOURCE
#include <stdio.h>
#include "xfree.h"
+#include "config.h"