public inbox for ecos-bugs@sourceware.org
help / color / mirror / Atom feed
From: bugzilla-daemon@bugs.ecos.sourceware.org
To: unassigned@bugs.ecos.sourceware.org
Subject: [Bug 1001522] Array index out of bounds in tftp_server.c
Date: Fri, 09 Mar 2012 05:13:00 -0000	[thread overview]
Message-ID: <20120309051253.027B62F78001@mail.ecoscentric.com> (raw)
In-Reply-To: <bug-1001522-777@http.bugs.ecos.sourceware.org/>

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001522

--- Comment #2 from Jonathan Larmour <jifl@ecoscentric.com> 2012-03-09 05:12:51 GMT ---
[ Sigh, I pressed tab too many times and accidentally prematurely submitted
this comment before it was finished. Ignore the previous comment. ]

Yes there's a bug here, but it's not quite that. That inner loop _should_ go
and close both the ipv4 and ipv6 sockets, because once another thread wakes up
to be the tftp server, it will want to open new ones of each. We'd leak sockets
if we didn't close both. So that bit's ok.

However, if the client sends an unsupported opcode, then this bit runs:
  tftpd_send_error(server->s[i],hdr,TFTP_EBADOP,&from_addr,from_len);
the problem here being that we've just closed server->s[i]. So that's broken.
Either it should make a new socket and use that for sending, or send the error
before it closes this server socket. A cheaty solution is probably something
like:

              int server_sock = -1; // at top of function
              // ...
              for (i=0; i < CYGNUM_NET_MAX_INET_PROTOS; i++) {
                if (server->s[i]) {
                  server_sock = server->s[i];
                  server->s[i] = 0;
                }
              }

and then use server_sock later on, and close it after the end of the 'switch'
block.

It's all rather crufty code - there's a window where the server socket is
closed and hasn't been reopened (which will cause ICMP port unreachable
messages to be sent, not merely have the TFTP request be ignored). It shouldn't
be closed at all really, but that would require other changes too. And I
dislike the server handle being a cast to an int of the server address. The
whole setup just isn't very good.

What do you think?

Jifl

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


  parent reply	other threads:[~2012-03-09  5:13 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-07 15:43 [Bug 1001522] New: " bugzilla-daemon
2012-03-09  5:09 ` [Bug 1001522] " bugzilla-daemon
2012-03-09  5:13 ` bugzilla-daemon [this message]
2012-03-09 15:55 ` bugzilla-daemon
2012-03-09 16:12 ` bugzilla-daemon
2012-03-09 16:32 ` bugzilla-daemon
2012-03-09 17:39 ` bugzilla-daemon
2012-03-11  3:56 ` bugzilla-daemon
2012-03-12 14:32 ` bugzilla-daemon
2012-08-09 16:05 ` bugzilla-daemon
2012-08-09 16:27 ` bugzilla-daemon
2012-08-09 17:02 ` bugzilla-daemon
2012-08-09 17:34 ` bugzilla-daemon
2012-08-10  9:57 ` bugzilla-daemon
2012-08-10 10:16 ` bugzilla-daemon
2012-03-07 15:43 [Bug 1001522] New: " bugzilla-daemon
2012-03-09  5:09 ` [Bug 1001522] " bugzilla-daemon
2012-03-09  5:13 ` bugzilla-daemon
2012-03-09 15:55 ` bugzilla-daemon
2012-03-09 16:12 ` bugzilla-daemon
2012-03-09 16:32 ` bugzilla-daemon
2012-03-09 17:39 ` bugzilla-daemon
2012-03-11  3:56 ` bugzilla-daemon
2012-03-12 14:32 ` bugzilla-daemon
2012-08-09 16:05 ` bugzilla-daemon
2012-08-09 16:28 ` bugzilla-daemon
2012-08-09 17:02 ` bugzilla-daemon
2012-08-09 17:34 ` bugzilla-daemon
2012-08-10  9:57 ` bugzilla-daemon
2012-08-10 10:16 ` bugzilla-daemon

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=20120309051253.027B62F78001@mail.ecoscentric.com \
    --to=bugzilla-daemon@bugs.ecos.sourceware.org \
    --cc=unassigned@bugs.ecos.sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).