* [B.A.T.M.A.N.] [PATCH] batadv-vis: don't leak socket fd in get_if_mac() @ 2014-01-19 15:01 Matthias Schiffer 2014-01-19 16:16 ` Antonio Quartulli 2014-01-20 10:52 ` Simon Wunderlich 0 siblings, 2 replies; 4+ messages in thread From: Matthias Schiffer @ 2014-01-19 15:01 UTC (permalink / raw) To: b.a.t.m.a.n Leaking an fd every time get_if_mac() is called causes a batadv-vis server process to hit the open file limit in a matter of hours when it is as low as 1024 (which it is on OpenWRT). Reported-by: Jan-Philipp Litza <janphilipp@litza.de> Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net> --- vis/vis.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/vis/vis.c b/vis/vis.c index dcb4db4..7a8e780 100644 --- a/vis/vis.c +++ b/vis/vis.c @@ -96,7 +96,7 @@ static uint8_t *str_to_mac(char *str) static int get_if_mac(char *ifname, uint8_t *mac) { struct ifreq ifr; - int sock; + int sock, ret; strncpy(ifr.ifr_name, ifname, IFNAMSIZ); @@ -105,7 +105,11 @@ static int get_if_mac(char *ifname, uint8_t *mac) return -1; } - if (ioctl(sock, SIOCGIFHWADDR, &ifr) == -1) { + ret = ioctl(sock, SIOCGIFHWADDR, &ifr); + + close(sock); + + if (ret == -1) { fprintf(stderr, "can't get MAC address: %s\n", strerror(errno)); return -1; } -- 1.8.5.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH] batadv-vis: don't leak socket fd in get_if_mac() 2014-01-19 15:01 [B.A.T.M.A.N.] [PATCH] batadv-vis: don't leak socket fd in get_if_mac() Matthias Schiffer @ 2014-01-19 16:16 ` Antonio Quartulli 2014-01-19 16:43 ` Matthias Schiffer 2014-01-20 10:52 ` Simon Wunderlich 1 sibling, 1 reply; 4+ messages in thread From: Antonio Quartulli @ 2014-01-19 16:16 UTC (permalink / raw) To: mschiffer; +Cc: The list for a Better Approach To Mobile Ad-hoc Networking [-- Attachment #1: Type: text/plain, Size: 648 bytes --] On 19/01/14 16:01, Matthias Schiffer wrote: > Leaking an fd every time get_if_mac() is called causes a batadv-vis server > process to hit the open file limit in a matter of hours when it is as low as > 1024 (which it is on OpenWRT). > > Reported-by: Jan-Philipp Litza <janphilipp@litza.de> > Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net> Matthias, what repository is this patch against? > --- > vis/vis.c | 8 ++++++-- I am puzzled because your commit subject says "batadv-vis" but the patch does not seem to be against batman-adv/batctl. Can you clarify please? Cheers, -- Antonio Quartulli [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH] batadv-vis: don't leak socket fd in get_if_mac() 2014-01-19 16:16 ` Antonio Quartulli @ 2014-01-19 16:43 ` Matthias Schiffer 0 siblings, 0 replies; 4+ messages in thread From: Matthias Schiffer @ 2014-01-19 16:43 UTC (permalink / raw) To: Antonio Quartulli Cc: The list for a Better Approach To Mobile Ad-hoc Networking [-- Attachment #1: Type: text/plain, Size: 771 bytes --] On 01/19/2014 05:16 PM, Antonio Quartulli wrote: > On 19/01/14 16:01, Matthias Schiffer wrote: >> Leaking an fd every time get_if_mac() is called causes a batadv-vis server >> process to hit the open file limit in a matter of hours when it is as low as >> 1024 (which it is on OpenWRT). >> >> Reported-by: Jan-Philipp Litza <janphilipp@litza.de> >> Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net> > > Matthias, > > what repository is this patch against? > >> --- >> vis/vis.c | 8 ++++++-- > > I am puzzled because your commit subject says "batadv-vis" but the patch > does not seem to be against batman-adv/batctl. Can you clarify please? > > Cheers, > > > Sorry, I forgot to change the subject to [PATCH alfred]... [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 263 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH] batadv-vis: don't leak socket fd in get_if_mac() 2014-01-19 15:01 [B.A.T.M.A.N.] [PATCH] batadv-vis: don't leak socket fd in get_if_mac() Matthias Schiffer 2014-01-19 16:16 ` Antonio Quartulli @ 2014-01-20 10:52 ` Simon Wunderlich 1 sibling, 0 replies; 4+ messages in thread From: Simon Wunderlich @ 2014-01-20 10:52 UTC (permalink / raw) To: The list for a Better Approach To Mobile Ad-hoc Networking > Leaking an fd every time get_if_mac() is called causes a batadv-vis server > process to hit the open file limit in a matter of hours when it is as low > as 1024 (which it is on OpenWRT). > > Reported-by: Jan-Philipp Litza <janphilipp@litza.de> > Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net> Applied in e99382e. If you use something like "alfred" in the header next time it will make it more unlikely for me to miss your patch. :) Thanks! Simon ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-01-20 10:52 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-01-19 15:01 [B.A.T.M.A.N.] [PATCH] batadv-vis: don't leak socket fd in get_if_mac() Matthias Schiffer 2014-01-19 16:16 ` Antonio Quartulli 2014-01-19 16:43 ` Matthias Schiffer 2014-01-20 10:52 ` Simon Wunderlich
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox