From c3db896887ec2c79d0fea9c29637709f5f844820 Mon Sep 17 00:00:00 2001 From: Andre Date: Sat, 6 May 2006 17:24:16 +0200 Subject: [PATCH] fix error log message Also, make recv_buffer() write a zero even if the underlying recv_bin_buffer() failed. --- net.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net.c b/net.c index bf35162f..d4472c0e 100644 --- a/net.c +++ b/net.c @@ -189,8 +189,11 @@ int recv_buffer(int fd, char *buf, ssize_t size) { int n; - if ((n = recv_bin_buffer(fd, buf, size - 1)) >= 0) + n = recv_bin_buffer(fd, buf, size - 1); + if (n >= 0) buf[n] = '\0'; + else + *buf = '\0'; return n; } @@ -514,8 +517,8 @@ int recv_pattern(int fd, const char *pattern, size_t bufsize) goto out; ret = 1; out: - free(buf); if (ret < 0) - PARA_NOTICE_LOG("did not receive pattern '%s'\n", buf); + PARA_NOTICE_LOG("did not receive pattern '%s'\n", pattern); + free(buf); return ret; } -- 2.39.5