From 3a23eb5f6cb07ab19ba2ed12ada082c7ffd3b93b Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Fri, 15 Jan 2010 23:41:04 +0100 Subject: [PATCH] Fix "off-by-one" bug in hddtemp found by valgrind --- src/hddtemp.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hddtemp.cc b/src/hddtemp.cc index 0f63e129..d01c7e75 100644 --- a/src/hddtemp.cc +++ b/src/hddtemp.cc @@ -133,7 +133,7 @@ static char *fetch_hddtemp_output(void) close(sockfd); } if (!rp) { - NORM_ERR("could not connect to mpd host"); + NORM_ERR("could not connect to hddtemp host"); goto GET_OUT; } @@ -175,6 +175,8 @@ static int read_hdd_val(const char *line, char **dev, short *val, char *unit, line_s = *saveptr; again: + if(!*p) + goto out_fail; /* read the device */ *dev = ++p; if (!(p = strchr(p, line_s[0])))