From 9e4c6648d2ff43a305d3754b4d896722803b9db3 Mon Sep 17 00:00:00 2001 From: millert Date: Tue, 2 Jun 2015 23:05:05 +0000 Subject: [PATCH] Don't leak value returned by cgetstr(). OK deraadt@ --- usr.sbin/sensorsd/sensorsd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/usr.sbin/sensorsd/sensorsd.c b/usr.sbin/sensorsd/sensorsd.c index 5e1a61bfbc2..e63cf9618d3 100644 --- a/usr.sbin/sensorsd/sensorsd.c +++ b/usr.sbin/sensorsd/sensorsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sensorsd.c,v 1.54 2015/01/16 06:40:20 deraadt Exp $ */ +/* $OpenBSD: sensorsd.c,v 1.55 2015/06/02 23:05:05 millert Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -721,13 +721,17 @@ parse_config_sdlim(struct sdlim_t *sdlim, char *cf) if (cgetstr(buf, "low", &ebuf) < 0) ebuf = NULL; p->lower = get_val(ebuf, 0, p->type); + free(ebuf); if (cgetstr(buf, "high", &ebuf) < 0) ebuf = NULL; p->upper = get_val(ebuf, 1, p->type); + free(ebuf); if (cgetstr(buf, "command", &ebuf) < 0) ebuf = NULL; - if (ebuf) - asprintf(&(p->command), "%s", ebuf); + if (ebuf != NULL) { + p->command = ebuf; + ebuf = NULL; + } free(buf); buf = NULL; if (p->lower != LLONG_MIN || p->upper != LLONG_MAX) -- 2.20.1