From fe439f2b965b9ee6e9dc9a6d8e2ecb443f86e788 Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 8 Jul 2013 15:48:16 +0000 Subject: replace a few (x)malloc with (x)calloc to prevent potential integer overflows; from Tiago Cunha --- xutil.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'xutil.c') diff --git a/xutil.c b/xutil.c index 6eeaf72..f7f2000 100644 --- a/xutil.c +++ b/xutil.c @@ -291,7 +291,7 @@ xu_ewmh_net_client_list(struct screen_ctx *sc) if (i == 0) return; - winlist = xmalloc(i * sizeof(*winlist)); + winlist = xcalloc(i, sizeof(*winlist)); TAILQ_FOREACH(cc, &Clientq, entry) winlist[j++] = cc->win; XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_CLIENT_LIST].atom, @@ -382,7 +382,7 @@ xu_ewmh_get_net_wm_state(struct client_ctx *cc, int *n) (u_char **)&p)) <= 0) return (NULL); - state = xmalloc(*n * sizeof(Atom)); + state = xcalloc(*n, sizeof(Atom)); memcpy(state, p, *n * sizeof(Atom)); XFree((char *)p); @@ -449,7 +449,7 @@ xu_ewmh_set_net_wm_state(struct client_ctx *cc) int n, i, j; oatoms = xu_ewmh_get_net_wm_state(cc, &n); - atoms = xmalloc((n + _NET_WM_STATES_NITEMS) * sizeof(Atom)); + atoms = xcalloc((n + _NET_WM_STATES_NITEMS), sizeof(Atom)); for (i = j = 0; i < n; i++) { if (oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_HORZ].atom && oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_VERT].atom) -- cgit 1.4.1 From 95710383580ecf66a58f27ecaa62dfe6c714c682 Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 10 Jul 2013 14:11:42 +0000 Subject: type fixes --- conf.c | 4 ++-- xutil.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'xutil.c') diff --git a/conf.c b/conf.c index 576f623..89dc18c 100644 --- a/conf.c +++ b/conf.c @@ -99,8 +99,8 @@ static char *color_binds[] = { void conf_screen(struct screen_ctx *sc) { - int i; - XftColor xc; + u_int i; + XftColor xc; sc->gap = Conf.gap; diff --git a/xutil.c b/xutil.c index f7f2000..f755a98 100644 --- a/xutil.c +++ b/xutil.c @@ -393,7 +393,7 @@ void xu_ewmh_handle_net_wm_state_msg(struct client_ctx *cc, int action, Atom first, Atom second) { - int i; + u_int i; static struct handlers { int atom; int property; -- cgit 1.4.1