-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
- --
// Gabriel VLASIU
//
// OpenGPG-KeyID : 44952F15
// OpenGPG-Fingerprint: 4AC5 7C26 2FE9 02DA 4906 24B2 D32B 7ED7 4495 2F15
// OpenGPG-URL : http://www.vlasiu.net/public.key
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (GNU/Linux)
iQIcBAEBCgAGBQJRXawyAAoJENMrftdElS8VlYYP/A2/34zsCZtxt08pp4/3WkZJ
QuhdwhEontuWbPq8Pl/kPXHpplcGWbQGptbvwWuHEyrFMiIRobjvoGjh0fQzpVAe
KxUj38s6iNbmtTExWk52cc2fEiu65Z2/mMROi8TT5r5BAtUCc8b0+p3q7j9Ki+v9
HYvAFf9xyh3jtR4Foq5n7R2lOsGUKAoqqwRNCKFPSBpCz+dBMMXLpot0/ni+raDV
22e4Vr9Fl+LBzEPvj0jQDowFXH5QLQwkCVFU3dscZdzIgDzx973VmVUjFe2Z9+77
K+DTvwd3y1lxChq63ZOBKD5KvNO2UfcaBbd/WNg6NhtvM3LIctgnvlF+PrVQgZw4
jrT6rkiMK0anDXDF4Glg2erI6SvXjj6rdxvzJNMOJyTxLFqGT4+RAUsy/rF1UWNd
YiMK1Nh3P2Cf/tlTbN2rAJ8CIz5HnAsQushtfm8Ckq9eay54lGgOfqcZ1eOSnL8Q
I6ZMjiTuDWFs7uWvHf4IYQANJWTH6N5Km2NJ3MdCL0ClhJQ2OxzWV1syl2cenOpT
oeMBQzCe0l3oovJ9WncCXyL8d4tQjeViMmzMay30q0opSWUhAeYMcTkvKnRAJMZA
LFFAgwBNpFxXBjOtakTcS4a+2OTA77N8HtGwTOPQZrP7lfsu+bu2NlSMVBORWBy2
Y4AKFeYwDGHa/ywTs+wA
=TCLo
-----END PGP SIGNATURE-----
From 9aaf0636c410438425724c5e24dc023b16acd03a Mon Sep 17 00:00:00 2001
From: Gabriel VLASIU <gabr...@vlasiu.net>
Date: Thu, 4 Apr 2013 13:29:30 +0300
Subject: [PATCH 1/6] Remove unused files.
---
wmbiff/wmgeneral/Makefile.am | 2 +-
wmbiff/wmgeneral/list.c | 155 -------------------------------------------
wmbiff/wmgeneral/list.h | 59 ----------------
wmbiff/wmgeneral/misc.c | 1 -
4 files changed, 1 insertion(+), 216 deletions(-)
delete mode 100644 wmbiff/wmgeneral/list.c
delete mode 100644 wmbiff/wmgeneral/list.h
diff --git a/wmbiff/wmgeneral/Makefile.am b/wmbiff/wmgeneral/Makefile.am
index 3e15428..ed65c43 100644
--- a/wmbiff/wmgeneral/Makefile.am
+++ b/wmbiff/wmgeneral/Makefile.am
@@ -1,5 +1,5 @@
noinst_LIBRARIES = libwmgeneral.a
-libwmgeneral_a_SOURCES = list.c list.h misc.c misc.h wmgeneral.c wmgeneral.h
+libwmgeneral_a_SOURCES = misc.c misc.h wmgeneral.c wmgeneral.h
MAINTAINERCLEANFILES = Makefile.in
diff --git a/wmbiff/wmgeneral/list.c b/wmbiff/wmgeneral/list.c
deleted file mode 100644
index b4d0685..0000000
--- a/wmbiff/wmgeneral/list.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/* Generic single linked list to keep various information
- Copyright (C) 1993, 1994 Free Software Foundation, Inc.
-
-
-Author: Kresten Krab Thorup
-
-Many modifications by Alfredo K. Kojima
-
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301 USA. */
-
-/* As a special exception, if you link this library with files compiled with
- GCC to produce an executable, this does not cause the resulting executable
- to be covered by the GNU General Public License. This exception does not
- however invalidate any other reasons why the executable file might be
- covered by the GNU General Public License. */
-
-#include "list.h"
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#include <stdlib.h>
-
-/* Return a cons cell produced from (head . tail) */
-
-INLINE LinkedList *list_cons(void *head, LinkedList * tail)
-{
- LinkedList *cell;
-
- cell = (LinkedList *) malloc(sizeof(LinkedList));
- cell->head = head;
- cell->tail = tail;
- return cell;
-}
-
-/* Return the length of a list, list_length(NULL) returns zero */
-
-INLINE int list_length(LinkedList * list)
-{
- int i = 0;
- while (list) {
- i += 1;
- list = list->tail;
- }
- return i;
-}
-
-/* Return the Nth element of LIST, where N count from zero. If N
- larger than the list length, NULL is returned */
-
-INLINE void *list_nth(int idx, LinkedList * list)
-{
- while (idx-- != 0) {
- if (list->tail)
- list = list->tail;
- else
- return 0;
- }
- return list->head;
-}
-
-/* Remove the element at the head by replacing it by its successor */
-
-INLINE void list_remove_head(LinkedList ** list)
-{
- if (!*list)
- return;
- if ((*list)->tail) {
- LinkedList *tail = (*list)->tail; /* fetch next */
- *(*list) = *tail; /* copy next to list head */
- free(tail); /* free next */
- } else { /* only one element in
list */
-
- free(*list);
- (*list) = 0;
- }
-}
-
-
-/* Remove the element with `car' set to ELEMENT */
-/*
-INLINE void
-list_remove_elem(LinkedList** list, void* elem)
-{
- while (*list)
- {
- if ((*list)->head == elem)
- list_remove_head(list);
- *list = (*list ? (*list)->tail : NULL);
- }
-}*/
-
-INLINE LinkedList *list_remove_elem(LinkedList * list, void *elem)
-{
- LinkedList *tmp;
-
- if (list) {
- if (list->head == elem) {
- tmp = list->tail;
- free(list);
- return tmp;
- }
- list->tail = list_remove_elem(list->tail, elem);
- return list;
- }
- return NULL;
-}
-
-
-/* Return element that has ELEM as car */
-
-INLINE LinkedList *list_find(LinkedList * list, void *elem)
-{
- while (list) {
- if (list->head == elem)
- return list;
- list = list->tail;
- }
- return NULL;
-}
-
-/* Free list (backwards recursive) */
-
-INLINE void list_free(LinkedList * list)
-{
- if (list) {
- list_free(list->tail);
- free(list);
- }
-}
-
-/* Map FUNCTION over all elements in LIST */
-
-INLINE void list_mapcar(LinkedList * list, void (*function) (void *))
-{
- while (list) {
- (*function) (list->head);
- list = list->tail;
- }
-}
diff --git a/wmbiff/wmgeneral/list.h b/wmbiff/wmgeneral/list.h
deleted file mode 100644
index c189208..0000000
--- a/wmbiff/wmgeneral/list.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Generic single linked list to keep various information
- Copyright (C) 1993, 1994 Free Software Foundation, Inc.
-
-Author: Kresten Krab Thorup
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301 USA. */
-
-/* As a special exception, if you link this library with files compiled with
- GCC to produce an executable, this does not cause the resulting executable
- to be covered by the GNU General Public License. This exception does not
- however invalidate any other reasons why the executable file might be
- covered by the GNU General Public License. */
-
-#ifndef __LIST_H_
-#define __LIST_H_
-
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-# define INLINE inline
-#else
-# define INLINE
-#endif
-
-typedef struct LinkedList {
- void *head;
- struct LinkedList *tail;
-} LinkedList;
-
-INLINE LinkedList *list_cons(void *head, LinkedList * tail);
-
-INLINE int list_length(LinkedList * list);
-
-INLINE void *list_nth(int n, LinkedList * list);
-
-INLINE void list_remove_head(LinkedList ** list);
-
-INLINE LinkedList *list_remove_elem(LinkedList * list, void *elem);
-
-INLINE void list_mapcar(LinkedList * list, void (*function) (void *));
-
-INLINE LinkedList *list_find(LinkedList * list, void *elem);
-
-INLINE void list_free(LinkedList * list);
-
-#endif
diff --git a/wmbiff/wmgeneral/misc.c b/wmbiff/wmgeneral/misc.c
index afb6b77..0b56b4b 100644
--- a/wmbiff/wmgeneral/misc.c
+++ b/wmbiff/wmgeneral/misc.c
@@ -21,7 +21,6 @@
#include <stdlib.h>
#include <string.h>
-#include "list.h"
#include "misc.h"
extern pid_t execCommand(const char *command)
--
1.8.1.4
From a5f9e6ba84316a50c84063f22dd90b1ca15befc1 Mon Sep 17 00:00:00 2001
From: Gabriel VLASIU <gabr...@vlasiu.net>
Date: Thu, 4 Apr 2013 13:56:46 +0300
Subject: [PATCH 2/6] Fix memory leaks pointed out by valgrind.
---
wmbiff/wmbiff/wmbiff.c | 6 ++++++
wmbiff/wmgeneral/wmgeneral.c | 9 +++++++++
2 files changed, 15 insertions(+)
diff --git a/wmbiff/wmbiff/wmbiff.c b/wmbiff/wmbiff/wmbiff.c
index 35b1fa8..b9d216d 100644
--- a/wmbiff/wmbiff/wmbiff.c
+++ b/wmbiff/wmbiff/wmbiff.c
@@ -1168,6 +1168,12 @@ static void do_biff(int argc, const char **argv)
free(skin_xpm); // added 3 jul 02, appeasing
valgrind
}
if (bkg_xpm != NULL) {
+ // Allocated in CreateBackingXPM()
+ free((void *)bkg_xpm[0]);
+ free((void *)bkg_xpm[2]);
+ int mem_block;
+ for (mem_block = 6; mem_block < 6 + wmbiff_mask_height;
mem_block++)
+ free((void *)bkg_xpm[mem_block]);
free(bkg_xpm);
}
}
diff --git a/wmbiff/wmgeneral/wmgeneral.c b/wmbiff/wmgeneral/wmgeneral.c
index 88d76fe..cb0fd6d 100644
--- a/wmbiff/wmgeneral/wmgeneral.c
+++ b/wmbiff/wmgeneral/wmgeneral.c
@@ -469,6 +469,11 @@ void openXwindow(int argc, const char *argv[],
int dummy = 0;
int i;
+ if (!wname) {
+ fprintf(stderr, "Unable to allocate memory for window name!\n");
+ abort();
+ }
+
for (i = 1; argv[i]; i++) {
if (!strcmp(argv[i], "-display")) {
display_name = argv[i + 1];
@@ -543,6 +548,7 @@ void openXwindow(int argc, const char *argv[],
}
XSetWMName(display, win, &name);
+ XFree(name.value);
/* Create GC for drawing */
@@ -609,4 +615,7 @@ void openXwindow(int argc, const char *argv[],
exit(1);
} */
}
+
+ if (wname)
+ free(wname);
}
--
1.8.1.4
From cf3492cef6fdf19fad10bdc74e314ca1037076ff Mon Sep 17 00:00:00 2001
From: Gabriel VLASIU <gabr...@vlasiu.net>
Date: Thu, 4 Apr 2013 13:57:28 +0300
Subject: [PATCH 3/6] More gnutls casts.
---
wmbiff/wmbiff/gnutls-common.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/wmbiff/wmbiff/gnutls-common.c b/wmbiff/wmbiff/gnutls-common.c
index d199d47..db6bd17 100644
--- a/wmbiff/wmbiff/gnutls-common.c
+++ b/wmbiff/wmbiff/gnutls-common.c
@@ -39,7 +39,8 @@ void print_x509_info(gnutls_session session, const char*
hostname)
{
gnutls_x509_crt crt;
const gnutls_datum *cert_list;
- unsigned int cert_list_size = 0, ret;
+ unsigned int cert_list_size = 0;
+ int ret;
char digest[20];
char serial[40];
char dn[256];
@@ -63,7 +64,7 @@ void print_x509_info(gnutls_session session, const char*
hostname)
printf(" - Got a certificate list of %d certificates.\n\n",
cert_list_size);
- for (j = 0; j < (unsigned int)cert_list_size; j++) {
+ for (j = 0; j < cert_list_size; j++) {
gnutls_x509_crt_init(&crt);
ret =
@@ -213,7 +214,7 @@ void print_openpgp_info(gnutls_session session, const char*
hostname)
size_t name_len = sizeof(name);
gnutls_openpgp_key crt;
const gnutls_datum *cert_list;
- int cert_list_size = 0;
+ unsigned int cert_list_size = 0;
time_t expiret;
time_t activet;
--
1.8.1.4
From b9b30c166e4f0c675f2f53f828ffef4238243849 Mon Sep 17 00:00:00 2001
From: Gabriel VLASIU <gabr...@vlasiu.net>
Date: Thu, 4 Apr 2013 15:54:05 +0300
Subject: [PATCH 4/6] Fix wmbiff restart.
---
wmbiff/wmbiff/wmbiff.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/wmbiff/wmbiff/wmbiff.c b/wmbiff/wmbiff/wmbiff.c
index b9d216d..2295f06 100644
--- a/wmbiff/wmbiff/wmbiff.c
+++ b/wmbiff/wmbiff/wmbiff.c
@@ -963,12 +963,16 @@ static void restart_wmbiff(int sig
#endif
)
{
- DMA(DEBUG_ERROR, "exec()'ing %s\n", restart_args[0]);
- sleep(1);
- execvp(restart_args[0], (char *const *) restart_args);
- DMA(DEBUG_ERROR, "exec of %s failed: %s\n",
- restart_args[0], strerror(errno));
- exit(EXIT_FAILURE);
+ if (restart_args) {
+ DMA(DEBUG_ERROR, "exec()'ing %s\n", restart_args[0]);
+ sleep(1);
+ execvp(restart_args[0], (char *const *) restart_args);
+ DMA(DEBUG_ERROR, "exec of %s failed: %s\n",
+ restart_args[0], strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ else
+ fprintf(stderr, "Unable to restart wmbiff: missing restart
arguments (NULL)!\n");
}
extern int x_socket(void)
@@ -1367,8 +1371,10 @@ int main(int argc, const char *argv[])
will need them if we have to restart on sigusr1 */
restart_args =
(const char **) malloc((argc + 1) * sizeof(const char *));
- memcpy(restart_args, argv, (argc) * sizeof(const char *));
- restart_args[argc] = NULL;
+ if (restart_args) {
+ memcpy(restart_args, argv, (argc) * sizeof(const char *));
+ restart_args[argc] = NULL;
+ }
parse_cmd(argc, argv, uconfig_file);
@@ -1397,5 +1403,10 @@ int main(int argc, const char *argv[])
signal(SIGPIPE, SIG_IGN); /* write() may fail */
do_biff(argc, argv);
+
+ // free resources
+ if (restart_args)
+ free(restart_args);
+
return 0;
}
--
1.8.1.4
From 3ddd7ebbe9fefa0cc0fc61130d68700b65910d5d Mon Sep 17 00:00:00 2001
From: Gabriel VLASIU <gabr...@vlasiu.net>
Date: Thu, 4 Apr 2013 15:56:53 +0300
Subject: [PATCH 5/6] Free memory when using a custom skin.
---
wmbiff/wmbiff/wmbiff.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/wmbiff/wmbiff/wmbiff.c b/wmbiff/wmbiff/wmbiff.c
index 2295f06..8a4fa07 100644
--- a/wmbiff/wmbiff/wmbiff.c
+++ b/wmbiff/wmbiff/wmbiff.c
@@ -88,6 +88,7 @@ static unsigned int num_mailboxes = 1;
static const int x_origin = 5;
static const int y_origin = 5;
static int forever = 1; /* keep running. */
+unsigned int custom_skin = 0; /* user has choose a custom skin */
extern Window win;
extern Window iconwin;
@@ -251,6 +252,7 @@ static int Read_Config_File(char *filename, int
*loopinterval)
continue;
} else if (!strcmp(setting, "skinfile")) {
skin_filename = strdup_ordie(value);
+ custom_skin = 1;
continue;
} else if (!strcmp(setting, "certfile")) { /* not yet
supported */
certificate_filename = strdup_ordie(value);
@@ -1407,6 +1409,8 @@ int main(int argc, const char *argv[])
// free resources
if (restart_args)
free(restart_args);
+ if (custom_skin)
+ free((void *)skin_filename);
return 0;
}
--
1.8.1.4
From 88f086365b71698c80c916ad1bfef3e757f3824a Mon Sep 17 00:00:00 2001
From: Gabriel VLASIU <gabr...@vlasiu.net>
Date: Thu, 4 Apr 2013 18:43:30 +0300
Subject: [PATCH 6/6] Fix segfault when -display or -geometry argument is
missing.
---
wmbiff/wmgeneral/wmgeneral.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/wmbiff/wmgeneral/wmgeneral.c b/wmbiff/wmgeneral/wmgeneral.c
index cb0fd6d..dc06cb6 100644
--- a/wmbiff/wmgeneral/wmgeneral.c
+++ b/wmbiff/wmgeneral/wmgeneral.c
@@ -475,11 +475,11 @@ void openXwindow(int argc, const char *argv[],
}
for (i = 1; argv[i]; i++) {
- if (!strcmp(argv[i], "-display")) {
+ if (!strcmp(argv[i], "-display") && i < argc - 1) {
display_name = argv[i + 1];
i++;
}
- if (!strcmp(argv[i], "-geometry")) {
+ if (!strcmp(argv[i], "-geometry") && i < argc - 1) {
geometry = argv[i + 1];
i++;
}
--
1.8.1.4