public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug network/18665] New: In send_dg, the recvfrom function is NOT always using the buffer size of a newly created buffer.
@ 2015-07-13 23:41 rhollida at ciena dot com
  2015-07-13 23:44 ` [Bug network/18665] " rhollida at ciena dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: rhollida at ciena dot com @ 2015-07-13 23:41 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18665

            Bug ID: 18665
           Summary: In send_dg, the recvfrom function is NOT always using
                    the buffer size of a newly created buffer.
           Product: glibc
           Version: 2.20
            Status: NEW
          Severity: normal
          Priority: P2
         Component: network
          Assignee: unassigned at sourceware dot org
          Reporter: rhollida at ciena dot com
  Target Milestone: ---

description:

When the thisanssizp pointer variable on line 1257 is updated, thisanssizp =
anssizp2, i.e assigned a new address,
this change causes the thisanssizp pointer variable used in the recvfrom
function on line 1282 to use the
wrong size if a new buffer is created after the thisanssizp address has been
changed at line 1257.

The size of the buffer used will be what was stored at the address assigned at
line 1257, and not the size of the newly created buffer.

The program will crash if the calculated size of the buffer used is 0. The
recvfrom function will
not crash, but any further accesses to the buffer where the bytes read was 0
from the recvfrom function
will crash the program. 

Initially at line 1230:
thisanssizp = anssizp;
-the thisanssizp gets assigned the address of anssizp when the send_dg function
is first called.

At line 1257:
thisanssizp = anssizp2;
-the thisanssizp address gets updated after we have received a packet.

At line 1273: 
*anssizp = MAXPACKET;
-the size of a new packet is assigned to *anssizp, and not *thisanssizp, when a
new buffer is created.

At line 1282:
recvfrom(pfd[0].fd, (char*)*thisansp, *thisanssizp, 
-the recvfrom function uses the size from *thisanssizp which is wrong.
-it can be seen here that thisansp will contain the address of a newly created
buffer, but the *thisanssizp, will contain the size from the aligned_resplen,
instead of MAXPACKET.

Fix:

Use the size pointer *thisanssizp, instead of *thisansp, when creating the new
buffer.

u_char *newp = malloc (MAXPACKET);
                        if (newp != NULL) {
                                <*anssizp = MAXPACKET;>     :REMOVED LINE:
                                *thisanssizp = MAXPACKET;   :ADDED LINE:
                                *thisansp = ans = newp;
                                if (thisansp == ansp2)
                                  *ansp2_malloced = 1;

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-02-10 19:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-13 23:41 [Bug network/18665] New: In send_dg, the recvfrom function is NOT always using the buffer size of a newly created buffer rhollida at ciena dot com
2015-07-13 23:44 ` [Bug network/18665] " rhollida at ciena dot com
2015-07-14 21:14 ` carlos at redhat dot com
2015-07-14 21:43 ` rhollida at ciena dot com
2015-07-14 21:54 ` rhollida at ciena dot com
2015-07-14 22:05 ` rhollida at ciena dot com
2015-07-24 11:32 ` fweimer at redhat dot com
2015-08-22 14:59 ` fweimer at redhat dot com
2021-02-10 19:27 ` [Bug network/18665] In send_dg, the recvfrom function is NOT always using the buffer size of a newly created buffer (CVE-2015-7547) bnnf-yellowbot at blurcompany dot com
2021-02-10 19:28 ` bnnf-yellowbot at blurcompany dot com

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).