From: "Serge E. Hallyn" <serue@us.ibm.com>
To: git@vger.kernel.org
Subject: [PATCH 1/7] cleanups: Fix resource leak and buffer overrun in daemon.c
Date: Mon, 17 Apr 2006 10:14:47 -0500 (CDT) [thread overview]
Message-ID: <20060417151447.D4FE619B90E@sergelap.hallyn.com> (raw)
In-Reply-To: 20060417145148.2F3CB19C90D@sergelap.hallyn.com
Address two reports from an automatic code analyzer:
1. In logreport, it is possible to write \0 one
character past the end of buf[].
2. In socksetup, socklist can be leaked when returning
if set_reuse_addr(). Note: dunno why this case returns...
Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
---
daemon.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
5b3e0254d34da582b7593084356c88a923f42a49
diff --git a/daemon.c b/daemon.c
index a1ccda3..7ac1bc7 100644
--- a/daemon.c
+++ b/daemon.c
@@ -65,8 +65,8 @@ static void logreport(int priority, cons
* we have space for our own LF and NUL after the "meat" of the
* message, so truncate it at maxlen - 1.
*/
- if (msglen > maxlen - 1)
- msglen = maxlen - 1;
+ if (msglen > maxlen - 2)
+ msglen = maxlen - 2;
else if (msglen < 0)
msglen = 0; /* Protect against weird return values. */
buflen += msglen;
@@ -535,6 +535,7 @@ static int socksetup(int port, int **soc
if (set_reuse_addr(sockfd)) {
close(sockfd);
+ free(socklist);
return 0; /* not fatal */
}
--
1.2.5
next prev parent reply other threads:[~2006-04-17 15:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-17 15:14 [PATCH 0/7] cleanups: intro Serge E. Hallyn
2006-04-17 15:14 ` [PATCH 2/7] cleanups: Fix potential bugs in connect.c Serge E. Hallyn
2006-04-17 15:14 ` [PATCH 3/7] cleanups: Remove unused vars from combine-diff.c Serge E. Hallyn
2006-04-17 15:14 ` Serge E. Hallyn [this message]
2006-04-17 21:42 ` [PATCH 1/7] cleanups: Fix resource leak and buffer overrun in daemon.c Junio C Hamano
2006-04-18 13:11 ` Serge E. Hallyn
2006-04-18 19:32 ` Junio C Hamano
2006-04-17 15:14 ` [PATCH 4/7] cleanups: Remove impossible case in quote.c Serge E. Hallyn
2006-04-17 15:14 ` [PATCH 6/7] cleanups: prevent leak of two strduped strings in config.c Serge E. Hallyn
2006-04-17 15:14 ` [PATCH 5/7] cleanups: Remove unused variable from sha1_file.c Serge E. Hallyn
2006-04-17 21:42 ` Junio C Hamano
2006-04-17 15:14 ` [PATCH 7/7] cleanups: remove unused variable from exec_cmd.c Serge E. Hallyn
2006-04-17 21:42 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060417151447.D4FE619B90E@sergelap.hallyn.com \
--to=serue@us.ibm.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox