aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorokan2013-07-08 15:48:16 +0000
committerokan2013-07-08 15:48:16 +0000
commita56db3439f26c4bda09fe7fdd665641680a6dad7 (patch)
tree766d854d9d4b379aba98573faecf89b906b2fc57
parent72d22295d234444996cb86245dcc179e24adc895 (diff)
downloadcwm-a56db3439f26c4bda09fe7fdd665641680a6dad7.tar.gz
replace a few (x)malloc with (x)calloc to prevent potential integer
overflows; from Tiago Cunha
Diffstat (limited to '')
-rw-r--r--group.c6
-rw-r--r--xutil.c8
2 files changed, 7 insertions, 7 deletions
diff --git a/group.c b/group.c
index bf8f694..9a66e74 100644
--- a/group.c
+++ b/group.c
@@ -16,7 +16,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: group.c,v 1.76 2013/05/06 16:03:11 okan Exp $
+ * $OpenBSD: group.c,v 1.77 2013/07/08 15:48:16 okan Exp $
*/
#include <sys/param.h>
@@ -430,8 +430,8 @@ group_update_names(struct screen_ctx *sc)
}
}
- strings = xmalloc((nstrings < CALMWM_NGROUPS ? CALMWM_NGROUPS :
- nstrings) * sizeof(*strings));
+ strings = xcalloc((nstrings < CALMWM_NGROUPS ? CALMWM_NGROUPS :
+ nstrings), sizeof(*strings));
p = (char *)prop_ret;
while (n < nstrings) {
diff --git a/xutil.c b/xutil.c
index 53e75a9..3d8292e 100644
--- a/xutil.c
+++ b/xutil.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: xutil.c,v 1.69 2013/06/10 21:37:30 okan Exp $
+ * $OpenBSD: xutil.c,v 1.70 2013/07/08 15:48:16 okan Exp $
*/
#include <sys/param.h>
@@ -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)