[Mono-bugs] [Bug 655637] New: UnixEndPoint not deserializing correctly

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Nov 23 18:57:42 EST 2010


https://bugzilla.novell.com/show_bug.cgi?id=655637

https://bugzilla.novell.com/show_bug.cgi?id=655637#c0


           Summary: UnixEndPoint not deserializing correctly
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: x86-64
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Mono.POSIX
        AssignedTo: miguel at novell.com
        ReportedBy: Novell at meinersbur.de
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: No


Description of Problem:

The method UnixEndPoint.Create(SocketAddress socketAddress) does not
deserialize correctly in two cases:
1. The UnixEndPointFilename is very long
2. Trying to get the RemoteEndPoint

Steps to reproduce the problem:
1. Compile program:

using System;

using System.Net.Sockets;

using Mono.Unix;



public class Program {


    static void Main() {

        var ep = new
UnixEndPoint("/tmp/meinmailmiteinemunglaublichuebertriebenlangennamen");



        var sock = new Socket (AddressFamily.Unix, SocketType.Stream,
ProtocolType.IP);

        sock.Bind(ep);

        sock.Listen(10);



        var sock2 = new Socket(AddressFamily.Unix, SocketType.Stream,
ProtocolType.IP);

        sock2.Connect(ep);

        sock2.Send(new byte[]{0xAB});



        var acc = sock.Accept();

        var localEp = acc.LocalEndPoint;

        Console.WriteLine("Local unix domain: " + localEp.ToString());

        var remoteEp = acc.RemoteEndPoint;

        Console.WriteLine("Remote unix domain: " + remoteEp.ToString());


    }



}



2. Run it


Actual Results:
Local unix domain: /tmp/meinmailmiteinemunglaubli
Unhandled Exception: System.OverflowException: Number overflow.
  at (wrapper managed-to-native) object:__icall_wrapper_mono_array_new_specific
(intptr,int)
  at Mono.Unix.UnixEndPoint.Create (System.Net.SocketAddress socketAddress)
[0x00000] in
/home/meinersbur/Desktop/mono/mcs/class/Mono.Posix/Mono.Unix/UnixEndPoint.cs:78 
  at System.Net.Sockets.Socket.get_RemoteEndPoint () [0x0005a] in
/home/meinersbur/Desktop/mono/mcs/class/System/System.Net.Sockets/Socket_2_1.cs:1070 
  at meinmail.Program.MainApp (System.String[] args) [0x0007a] in
/home/meinersbur/Projects/meinmail/meinmail/Program.cs:31 
  at meinmail.Program.Main () [0x00000] in
/home/meinersbur/Projects/meinmail/meinmail/Program.cs:12 

Expected Results:
Local unix domain: /tmp/meinmailmiteinemunglaublichunduebertriebenlangennamen
Remote unix domain:



Additional Information:

Case 1 is probably result of the limited space in 'struct sockaddr' to store
the filename. I'd assume 13 ASCII characters (+ one NUL) corresponding to the
structure's 'char sa_data[14]', but obviously it remembers more characters.
However, it successfully created that file and one can connect to it. The
problem remains that it prints garbage when the filename is trimmed. In this
example, it prints '\x01', in other cases I also saw it print other garbage
like "�v" ("\uFFFD\x10v\x01"). Clearly, it shouldn't do so.

Case 2 is is the result of the remote endpoint having no name. The
SocketInformation consists of a byte array with two entries, but UnixEndPoint
expects at least a filename consisting of a terminating NUL byte. Since it is
missing, it allocates 'new byte[-1]', which causes the exception.

Using git commit bcdbd24355554f16e0a0bf86f7624ad731b46ade

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list