Package: wmcube Version: 0.98-6.1 Severity: important Tags: patch The support for multiple CPUs in wmcube (through the -c option) is currently broken.
Attached is a patch against the wmcube-0.98.6.1 correcting this issue. The fix actually skips irrelevant lines in /proc/stat. The patch also switches the package hand-made patch system to dpatch, as the previous system was not able to deapply patches in the proper order. Regards, -- Jérémy
diff -urN wmcube-0.98/debian/control wmcube-0.98.fixed/debian/control --- wmcube-0.98/debian/control 2006-09-10 17:13:07.000000000 +0200 +++ wmcube-0.98.fixed/debian/control 2006-09-10 17:01:18.000000000 +0200 @@ -2,7 +2,7 @@ Section: x11 Priority: optional Maintainer: Filip Van Raemdonck <[EMAIL PROTECTED]> -Build-Depends: debhelper (>= 5), libx11-dev, libxext-dev, libxpm-dev +Build-Depends: debhelper (>= 5), dpatch, libx11-dev, libxext-dev, libxpm-dev Standards-Version: 3.6.2.1 Package: wmcube diff -urN wmcube-0.98/debian/patches/00list wmcube-0.98.fixed/debian/patches/00list --- wmcube-0.98/debian/patches/00list 1970-01-01 01:00:00.000000000 +0100 +++ wmcube-0.98.fixed/debian/patches/00list 2006-09-10 16:58:54.000000000 +0200 @@ -0,0 +1,3 @@ +01datapath +02secfix +03smpfix diff -urN wmcube-0.98/debian/patches/01datapath.dpatch wmcube-0.98.fixed/debian/patches/01datapath.dpatch --- wmcube-0.98/debian/patches/01datapath.dpatch 1970-01-01 01:00:00.000000000 +0100 +++ wmcube-0.98.fixed/debian/patches/01datapath.dpatch 2006-09-10 16:59:31.000000000 +0200 @@ -0,0 +1,19 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 01datapath.dpatch +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Fix object path according to Debian rules. + [EMAIL PROTECTED]@ +diff -urNad wmcube-0.98~/wmcube/wmcube.c wmcube-0.98/wmcube/wmcube.c +--- wmcube-0.98~/wmcube/wmcube.c 2000-10-23 22:11:47.000000000 +0200 ++++ wmcube-0.98/wmcube/wmcube.c 2006-09-10 16:54:28.620250000 +0200 +@@ -138,7 +138,7 @@ + + char *rotdiv = {"25"}; + char *rotstep = {"1"}; +- char *obj_filename = {""}; ++ char *obj_filename = {"/usr/share/wmcube/"}; + int rot; + int cube_color = 1; + int c = 0; diff -urN wmcube-0.98/debian/patches/02secfix.dpatch wmcube-0.98.fixed/debian/patches/02secfix.dpatch --- wmcube-0.98/debian/patches/02secfix.dpatch 1970-01-01 01:00:00.000000000 +0100 +++ wmcube-0.98.fixed/debian/patches/02secfix.dpatch 2006-09-10 17:03:56.000000000 +0200 @@ -0,0 +1,97 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 02secfix.dpatch +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Security fixes. + [EMAIL PROTECTED]@ +diff -urNad wmcube-0.98~/wmcube/wmcube.c wmcube-0.98/wmcube/wmcube.c +--- wmcube-0.98~/wmcube/wmcube.c 2006-09-10 16:54:58.962146250 +0200 ++++ wmcube-0.98/wmcube/wmcube.c 2006-09-10 16:55:06.494617000 +0200 +@@ -346,7 +346,7 @@ + char *tmp = malloc(32); + int oldzoff = 3600; + +- sprintf(tmp,"V%s",WMCUBE_VERSION); ++ snprintf(tmp, 32, "V%s",WMCUBE_VERSION); + + RedrawWindow(); + BlitString("WMCUBE",13,22); +@@ -564,7 +564,7 @@ + newx -= CHAR_WIDTH; + } + +- sprintf(buf, "%02i", num); ++ snprintf(buf, 1024, "%02i", num); + + BlitString(buf, newx, y); + } +@@ -913,7 +913,7 @@ + exit(0); + } + +- fscanf(fp,"%s",tmp); ++ fscanf(fp,"%63s",tmp); + + if (strcmp(tmp,"WMCUBE_COORDINATES") != 0) { + printf("\nError in objectfile: it must start with WMCUBE_COORDINATES\n\n"); +@@ -921,7 +921,7 @@ + exit(0); + } + +- fscanf(fp,"%s",tmp); ++ fscanf(fp,"%63s",tmp); + counter = atoi(tmp); + + while ((strcmp(tmp,"WMCUBE_LINES") != 0) && (strcmp(tmp,"WMCUBE_PLANES") != 0)) { +@@ -938,7 +938,7 @@ + fclose(fp); + exit(0); + } +- fscanf(fp,"%s",tmp); ++ fscanf(fp,"%63s",tmp); + + if (feof(fp)) { + printf("\nError in objectfile: you must have a section WMCUBE_LINES or WMCUBE_PLANES\n\n"); +@@ -1040,18 +1040,20 @@ + char cpuid[6]; + char check_cpu[6]; + +- sprintf(check_cpu, "cpu%d", which_cpu); ++ snprintf(check_cpu, 6, "cpu%d", which_cpu); + + if ((fp = fopen("/proc/stat","rb")) == NULL) { + perror("/proc/stat required for this system"); + return -1; + } + +- if (which_cpu == -1) ++ if (which_cpu == -1) { ++ fclose (fp); + return 0; +- ++ } ++ + for (i = -2; i < which_cpu; i++) { +- fscanf(fp, "%s", cpuid); ++ fscanf(fp, "%5s %*d %*d %*d %*d", cpuid); + } + + if (strcmp(check_cpu,cpuid) != 0) { +@@ -1059,6 +1061,7 @@ + "sure you have an SMP system?\n",check_cpu); + return -1; + } ++ fclose (fp); + return (0); + } + +@@ -1072,7 +1075,7 @@ + fp = fopen("/proc/stat","rt"); + + for (i = -2; i < which_cpu; i++) { +- fscanf(fp,"%s %d %d %d %d",cpuid,&cpu,&nice,&system,&idle); ++ fscanf(fp,"%5s %d %d %d %d",cpuid,&cpu,&nice,&system,&idle); + } + + fclose(fp); diff -urN wmcube-0.98/debian/patches/03smpfix.dpatch wmcube-0.98.fixed/debian/patches/03smpfix.dpatch --- wmcube-0.98/debian/patches/03smpfix.dpatch 1970-01-01 01:00:00.000000000 +0100 +++ wmcube-0.98.fixed/debian/patches/03smpfix.dpatch 2006-09-10 17:00:15.000000000 +0200 @@ -0,0 +1,71 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 03smpfix.dpatch +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Fix /proc/stat reading when a specific CPU is listed. + [EMAIL PROTECTED]@ +diff -urNad wmcube-0.98~/wmcube/wmcube.c wmcube-0.98/wmcube/wmcube.c +--- wmcube-0.98~/wmcube/wmcube.c 2006-09-10 16:55:33.988335250 +0200 ++++ wmcube-0.98/wmcube/wmcube.c 2006-09-10 16:57:39.668189750 +0200 +@@ -1037,28 +1037,29 @@ + { + FILE *fp; + int i; ++ static char dummy[4096]; + char cpuid[6]; + char check_cpu[6]; + +- snprintf(check_cpu, 6, "cpu%d", which_cpu); ++ sprintf(check_cpu, "cpu%d", which_cpu); + + if ((fp = fopen("/proc/stat","rb")) == NULL) { + perror("/proc/stat required for this system"); + return -1; + } + +- if (which_cpu == -1) { +- fclose (fp); ++ if (which_cpu == -1) + return 0; +- } +- +- for (i = -2; i < which_cpu; i++) { +- fscanf(fp, "%5s %*d %*d %*d %*d", cpuid); ++ ++ /* Skip irrelevant CPU lines */ ++ for (i = -1; i < which_cpu; i++) { ++ fgets(dummy, 4096, fp); + } + +- if (strcmp(check_cpu,cpuid) != 0) { ++ if (fscanf(fp, "%s", cpuid) > 0 && strcmp(check_cpu,cpuid) != 0) { + fprintf(stderr, "ERROR: could not read cpu-load on %s. Are you " + "sure you have an SMP system?\n",check_cpu); ++ fclose (fp); + return -1; + } + fclose (fp); +@@ -1068,15 +1069,19 @@ + int calc_cpu_total() { + int total, used, t=0, i; + static int previous_total = 0, previous_used = 0; ++ static char dummy[4096]; + char cpuid[6]; + int cpu,nice,system,idle; + FILE *fp; + + fp = fopen("/proc/stat","rt"); + +- for (i = -2; i < which_cpu; i++) { +- fscanf(fp,"%5s %d %d %d %d",cpuid,&cpu,&nice,&system,&idle); +- } ++ /* Skip irrelevant CPU lines */ ++ for (i = -1; i < which_cpu; i++) { ++ fgets(dummy, 4096, fp); ++ } ++ ++ fscanf(fp,"%s %d %d %d %d",cpuid,&cpu,&nice,&system,&idle); + + fclose(fp); + diff -urN wmcube-0.98/debian/patches/datapath.dpatch wmcube-0.98.fixed/debian/patches/datapath.dpatch --- wmcube-0.98/debian/patches/datapath.dpatch 2006-09-10 17:13:07.000000000 +0200 +++ wmcube-0.98.fixed/debian/patches/datapath.dpatch 1970-01-01 01:00:00.000000000 +0100 @@ -1,32 +0,0 @@ -#! /bin/sh -e - -# DP: Modified - -if [ $# -ne 1 ]; then - echo >&2 "$0: script expects -patch|-unpatch as argument" - exit 1 -fi -case "$1" in - -patch) patch -f -p0 < $0;; - -unpatch) patch -f -R -p0 < $0;; - *) - echo >&2 "$0: script expects -patch|-unpatch as argument" - exit 1 -esac -exit 0 - ---- wmcube/wmcube.c.orig -+++ wmcube/wmcube.c -@@ -136,11 +136,11 @@ - int loop = 0; - XEvent Event; - - char *rotdiv = {"25"}; - char *rotstep = {"1"}; -- char *obj_filename = {""}; -+ char *obj_filename = {"/usr/share/wmcube/"}; - int rot; - int cube_color = 1; - int c = 0; - int invert_speed = 0; - diff -urN wmcube-0.98/debian/patches/secfix.dpatch wmcube-0.98.fixed/debian/patches/secfix.dpatch --- wmcube-0.98/debian/patches/secfix.dpatch 2006-09-10 17:13:07.000000000 +0200 +++ wmcube-0.98.fixed/debian/patches/secfix.dpatch 1970-01-01 01:00:00.000000000 +0100 @@ -1,130 +0,0 @@ -#! /bin/sh -e - -# DP: Modified - -if [ $# -ne 1 ]; then - echo >&2 "$0: script expects -patch|-unpatch as argument" - exit 1 -fi -case "$1" in - -patch) patch -f -p0 < $0;; - -unpatch) patch -f -R -p0 < $0;; - *) - echo >&2 "$0: script expects -patch|-unpatch as argument" - exit 1 -esac -exit 0 - ---- wmcube/wmcube.c.orig -+++ wmcube/wmcube.c -@@ -344,11 +344,11 @@ - void startup_seq() - { - char *tmp = malloc(32); - int oldzoff = 3600; - -- sprintf(tmp,"V%s",WMCUBE_VERSION); -+ snprintf(tmp, 32, "V%s",WMCUBE_VERSION); - - RedrawWindow(); - BlitString("WMCUBE",13,22); - BlitString(tmp,15,31); - RedrawWindow(); -@@ -562,11 +562,11 @@ - if (num > 999) - { - newx -= CHAR_WIDTH; - } - -- sprintf(buf, "%02i", num); -+ snprintf(buf, 1024, "%02i", num); - - BlitString(buf, newx, y); - } - - void line(int x1, int y1, int x2, int y2, int c) -@@ -911,19 +911,19 @@ - if ((fp = fopen(filename,"rt")) == NULL) { - printf("\nERROR: wmCube object-file not found (%s).\n\n",filename); - exit(0); - } - -- fscanf(fp,"%s",tmp); -+ fscanf(fp,"%63s",tmp); - - if (strcmp(tmp,"WMCUBE_COORDINATES") != 0) { - printf("\nError in objectfile: it must start with WMCUBE_COORDINATES\n\n"); - fclose(fp); - exit(0); - } - -- fscanf(fp,"%s",tmp); -+ fscanf(fp,"%63s",tmp); - counter = atoi(tmp); - - while ((strcmp(tmp,"WMCUBE_LINES") != 0) && (strcmp(tmp,"WMCUBE_PLANES") != 0)) { - - matrix = (float **)realloc(matrix,(i+1)*sizeof(float *)); mem_alloc_error(matrix); -@@ -936,11 +936,11 @@ - printf("\nError in objectfile (WMCUBE_COORDINATES section):\n" - "the coordinates must be listed in order 1..n\n\n"); - fclose(fp); - exit(0); - } -- fscanf(fp,"%s",tmp); -+ fscanf(fp,"%63s",tmp); - - if (feof(fp)) { - printf("\nError in objectfile: you must have a section WMCUBE_LINES or WMCUBE_PLANES\n\n"); - fclose(fp); - exit(0); -@@ -1038,29 +1038,32 @@ - FILE *fp; - int i; - char cpuid[6]; - char check_cpu[6]; - -- sprintf(check_cpu, "cpu%d", which_cpu); -+ snprintf(check_cpu, 6, "cpu%d", which_cpu); - - if ((fp = fopen("/proc/stat","rb")) == NULL) { - perror("/proc/stat required for this system"); - return -1; - } - -- if (which_cpu == -1) -+ if (which_cpu == -1) { -+ fclose (fp); - return 0; -- -+ } -+ - for (i = -2; i < which_cpu; i++) { -- fscanf(fp, "%s", cpuid); -+ fscanf(fp, "%5s %*d %*d %*d %*d", cpuid); - } - - if (strcmp(check_cpu,cpuid) != 0) { - fprintf(stderr, "ERROR: could not read cpu-load on %s. Are you " - "sure you have an SMP system?\n",check_cpu); - return -1; - } -+ fclose (fp); - return (0); - } - - int calc_cpu_total() { - int total, used, t=0, i; -@@ -1073,11 +1073,11 @@ - FILE *fp; - - fp = fopen("/proc/stat","rt"); - - for (i = -2; i < which_cpu; i++) { -- fscanf(fp,"%s %d %d %d %d",cpuid,&cpu,&nice,&system,&idle); -+ fscanf(fp,"%5s %d %d %d %d",cpuid,&cpu,&nice,&system,&idle); - } - - fclose(fp); - - used = cpu + system + use_nice*nice; diff -urN wmcube-0.98/debian/patches/smpfix.dpatch wmcube-0.98.fixed/debian/patches/smpfix.dpatch --- wmcube-0.98/debian/patches/smpfix.dpatch 2006-09-10 17:13:07.000000000 +0200 +++ wmcube-0.98.fixed/debian/patches/smpfix.dpatch 1970-01-01 01:00:00.000000000 +0100 @@ -1,47 +0,0 @@ -#! /bin/sh -e - -# DP: Modified - -if [ $# -ne 1 ]; then - echo >&2 "$0: script expects -patch|-unpatch as argument" - exit 1 -fi -case "$1" in - -patch) patch -f -p0 < $0;; - -unpatch) patch -f -R -p0 < $0;; - *) - echo >&2 "$0: script expects -patch|-unpatch as argument" - exit 1 -esac -exit 0 - ---- wmcube/wmcube.c.orig-bak -+++ wmcube/wmcube.c -@@ -1045,22 +1045,25 @@ - if ((fp = fopen("/proc/stat","rb")) == NULL) { - perror("/proc/stat required for this system"); - return -1; - } - -- if (which_cpu == -1) -+ if (which_cpu == -1) { -+ fclose (fp); - return 0; -+ } - - for (i = -2; i < which_cpu; i++) { -- fscanf(fp, "%s", cpuid); -+ fscanf(fp, "%5s %*d %*d %*d %*d", cpuid); - } - - if (strcmp(check_cpu,cpuid) != 0) { - fprintf(stderr, "ERROR: could not read cpu-load on %s. Are you " - "sure you have an SMP system?\n",check_cpu); - return -1; - } -+ fclose (fp); - return (0); - } - - int calc_cpu_total() { - int total, used, t=0, i; diff -urN wmcube-0.98/debian/rules wmcube-0.98.fixed/debian/rules --- wmcube-0.98/debian/rules 2006-09-10 17:13:07.000000000 +0200 +++ wmcube-0.98.fixed/debian/rules 2006-09-10 16:52:00.000000000 +0200 @@ -23,16 +23,18 @@ INSTALL_PROGRAM += -s endif -debian_patches = datapath secfix +# Include dpatch stuff. +include /usr/share/dpatch/dpatch.make -build: patched-stamp build-stamp -build-stamp: +build: build-stamp +build-stamp: patch-stamp dh_testdir # perl -pi -e 's/-DX_LOCALE//g;' Makefile $(MAKE) -C wmcube CFLAGS="$(CFLAGS)" touch build-stamp -clean: reverse-patches +clean: clean-patched unpatch +clean-patched: dh_testdir dh_testroot rm -f build-stamp @@ -78,50 +80,6 @@ @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary - -# --------------------------------------------------------------------------- -# various rules to unpack addons and (un)apply patches. -# borrowed from egcs package - -patch_dir = debian/patches - -apply-patches: patched-stamp -reverse-patches: - @for stamp in none patched-*; do \ - case "$$stamp" in none|patched-stamp|patched-\*) continue; esac; \ - patch=`echo $$stamp | sed -e 's/patched-//'`; \ - echo "trying to revert patch $$patch ..."; \ - if [ -x $(patch_dir)/$$patch.dpatch ]; then true; else \ - chmod +x $(patch_dir)/$$patch.dpatch; fi; \ - if $(patch_dir)/$$patch.dpatch -unpatch; then \ - echo "reverted $$patch patch."; \ - rm -f $$stamp; \ - else \ - echo "error in reverting $$patch patch."; \ - exit 1; \ - fi; \ - done - @echo "Removing patched-stamp" - @rm -f patched-stamp - -patched-%: $(patch_dir)/%.dpatch - @if [ -x $< ]; then true; else chmod +x $<; fi - @if [ -f $@ ]; then \ - echo "$* patches already applied."; exit 1; \ - fi - $< -patch - @echo "$* patches applied." > $@ - -patched-stamp: $(foreach p,$(debian_patches),patched-$(p)) - @echo -e "\nPatches applied:" >> pxxx - @for i in none $(debian_patches); do \ - if [ -r debian/patches/$$i.dpatch ]; then \ - echo -e "\n$$i:" >> pxxx; \ - sed -n 's/^# *DP: */ /p' debian/patches/$$i.dpatch >> pxxx; \ - fi \ - done - @echo "Writing patched-stamp" - @mv -f pxxx patched-stamp +.PHONY: build clean clean-patched binary-indep binary-arch binary patch unpatch # vi: ts=8 sw=8 ai nowrap
signature.asc
Description: Digital signature