Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip extra null characters in socketAddress #2145

Merged
merged 2 commits into from
Mar 2, 2016
Merged

Conversation

dlech
Copy link
Contributor

@dlech dlech commented Oct 17, 2015

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=35004.

Also remove unnecessary copying of array.


string name = Encoding.Default.GetString (bytes);
string name = Encoding.Default.GetString (bytes, 2, socketAddress.Size - 2 - 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bytes doesn't exist here as you deleted it above.

@akoeplinger
Copy link
Member

Can you please add the unit test to https://github.com/mono/mono/tree/master/mcs/class/Mono.Posix/Test/Mono.Unix? (we don't use the Assert.That () NUnit style, so please adapt to the existing style).

@dlech
Copy link
Contributor Author

dlech commented Oct 17, 2015

Thanks for the review. Yes, I will be glad to fix this up.

@dlech dlech force-pushed the patch-2 branch 3 times, most recently from fc38c5e to 6f7485c Compare October 17, 2015 17:44
@dlech
Copy link
Contributor Author

dlech commented Oct 17, 2015

Well, I added some unit tests, but it turns out that my fix doesn't work. I am getting two extra random characters when running the unit test instead of two extra null characters. I'll have to do some more digging to figure it out - unless someone else has any insight.

@dlech dlech force-pushed the patch-2 branch 4 times, most recently from 0a386c4 to 51bfbd1 Compare October 17, 2015 19:55
@dlech
Copy link
Contributor Author

dlech commented Oct 17, 2015

OK. Should be good now. I've added a unit test for the original problem that I was seeing (UnixListenerTest) and a unit test for the method that was actually changed (UnixEndPointTest). Both of these tests fail on mono master. Then I added a separate commit with a new fix that is more robust than the previous one.

@akoeplinger
Copy link
Member

build

@akoeplinger
Copy link
Member

Looks good to me! I've triggered a build on the CI (expect a few test cases failing right now, they're unrelated).

Any other comments from people more familiar with the code?

@dlech
Copy link
Contributor Author

dlech commented Oct 17, 2015

The build failed because I was using Path.GetFullPath() in one of the unit tests and the build server has a very long path name where the tests are running. Unix sockets are limited to 108 characters in the path (see man 7 unix). This is why it worked locally for me and failed in CI. We have to have an absolute path. I tried it and the test fails if I use a relative path. So, I have replaced Path.GetFullPath() with Path.GetTempFileName(), which should hopefully get a shorter file name in CI. Please give it another go.

@akoeplinger
Copy link
Member

build

@akoeplinger
Copy link
Member

It looks good to me.

@jonpryor can you please take a look as well?

@akoeplinger
Copy link
Member

@dlech would you mind rebasing this to get rid of the merge conflicts?

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
@dlech
Copy link
Contributor Author

dlech commented Mar 1, 2016

rebased

@akoeplinger
Copy link
Member

build

@akoeplinger
Copy link
Member

LGTM.

akoeplinger added a commit that referenced this pull request Mar 2, 2016
Strip extra null characters in socketAddress
@akoeplinger akoeplinger merged commit 7503fd6 into mono:master Mar 2, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Strip extra null characters in socketAddress

Commit migrated from mono/mono@7503fd6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants