Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lechner <david@lechnology.com>2015-10-17 22:40:54 +0300
committerDavid Lechner <david@lechnology.com>2016-03-01 19:52:17 +0300
commitabad3612068e7333956106e7be02d9ce9e346f92 (patch)
tree5645eae9cdf90b727257e89168031c01b293046b /mcs/class/Mono.Posix
parent0f0d4804b19543fef3f64abc2e3b2941ab19fa62 (diff)
Fix marshaling of file name in Mono.Unix.UnixEndPoint.Create()
In some cases, the null terminator in the SocketAddress may not be the last character. This changes the algorithm to ignore the null terminator and anything after it instead of assuming that the last character is the null terminator. Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=35004
Diffstat (limited to 'mcs/class/Mono.Posix')
-rw-r--r--mcs/class/Mono.Posix/Mono.Unix/UnixEndPoint.cs10
1 files changed, 8 insertions, 2 deletions
diff --git a/mcs/class/Mono.Posix/Mono.Unix/UnixEndPoint.cs b/mcs/class/Mono.Posix/Mono.Unix/UnixEndPoint.cs
index d86dd7cf7dc..d7a7f0c6b86 100644
--- a/mcs/class/Mono.Posix/Mono.Unix/UnixEndPoint.cs
+++ b/mcs/class/Mono.Posix/Mono.Unix/UnixEndPoint.cs
@@ -82,12 +82,18 @@ namespace Mono.Unix
uep.filename = "";
return uep;
}
- byte [] bytes = new byte [socketAddress.Size - 2 - 1];
+ int size = socketAddress.Size - 2;
+ byte [] bytes = new byte [size];
for (int i = 0; i < bytes.Length; i++) {
bytes [i] = socketAddress [i + 2];
+ // There may be junk after the null terminator, so ignore it all.
+ if (bytes [i] == 0) {
+ size = i;
+ break;
+ }
}
- string name = Encoding.Default.GetString (bytes);
+ string name = Encoding.Default.GetString (bytes, 0, size);
return new UnixEndPoint (name);
}