projects
/
paraslash.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3d957db
)
net.c: Fix a memory leak in makesock().
author
Andre Noll
<maan@systemlinux.org>
Thu, 17 Jan 2008 20:40:38 +0000
(21:40 +0100)
committer
Andre Noll
<maan@systemlinux.org>
Thu, 17 Jan 2008 20:40:38 +0000
(21:40 +0100)
"port" was allocated dynamically but never freed. Fix it by
using a static buffer instead. This buffer can not overflow as
"port_number" is an unsigned short, so its decimal representation
consists of at most 5 digits.
net.c
patch
|
blob
|
history
diff --git
a/net.c
b/net.c
index
2db3405
..
10fc121
100644
(file)
--- a/
net.c
+++ b/
net.c
@@
-147,10
+147,11
@@
int makesock(unsigned l3type, unsigned l4type, int passive,
{
struct addrinfo *local = NULL, *src,
*remote = NULL, *dst, hints;
- char *port = make_message("%u", port_number);
int rc, on = 1, sockfd = -1,
socktype = sock_type(l4type);
+ char port[6]; /* port number has at most 5 digits */
+ sprintf(port, "%u", port_number);
/* Set up address hint structure */
memset(&hints, 0, sizeof(hints));
hints.ai_family = l3type;