Closed Bug 1331810 Opened 7 years ago Closed 7 years ago

NSPR prevents sending 0-size UDP message on Windows

Categories

(NSPR :: NSPR, defect)

All
Windows
defect
Not set
normal

Tracking

(firefox54 fixed)

RESOLVED FIXED
Tracking Status
firefox54 --- fixed

People

(Reporter: drno, Assigned: drno)

References

Details

Attachments

(1 file)

Over in bug 1317946 I'm trying to write a xpcshell test which sends an empty UDP packet (0 bytes payload - just the IP and UDP header) and receives it again. This works fine on Linux and Mac, but fails on Windows.

The reason is that on Mac (and probably Linux as well) NSPR uses this code in NSPR allows to send an empty packet: http://searchfox.org/mozilla-central/rev/790b2cb423ea1ecb5746722d51633caec9bab95a/nsprpub/pr/src/pthreads/ptio.c#2017

But on Windows the while loop here http://searchfox.org/mozilla-central/rev/790b2cb423ea1ecb5746722d51633caec9bab95a/nsprpub/pr/src/io/prsocket.c#754 assume that there needs to be at least one byte of data to be send. This assumption is wrong for UDP.

BTW the same wrong assumption is then also made here: http://searchfox.org/mozilla-central/rev/790b2cb423ea1ecb5746722d51633caec9bab95a/nsprpub/pr/src/md/windows/w95sock.c#297
MSDN agrees:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms740148(v=vs.85).aspx
> Calling sendto with a len of zero is permissible and will return zero as a
> valid value. For message-oriented sockets, a zero-length transport datagram
> is sent.
Assignee: nobody → drno
See Also: → 1332065
Comment on attachment 8828085 [details]
Bug 1331810: enable sending of 0 size UDP packets in NSPR.

https://reviewboard.mozilla.org/r/105600/#review110692

I had no idea that was a valid thing you could do, but OK. The changes are straightforward.
Attachment #8828085 - Flags: review?(ted) → review+
https://hg.mozilla.org/mozilla-central/rev/9882b8c0d5fb
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
You did it wrong.

NSPR is a separate product, and Firefox should only use released snapshots of NSPR.

Please don't make local changes to the copy of NSPR in directory /nsprpub (except when you make a try build).

Instead, please suggest your changes to the NSPR component, and ask for a new NSPR snapshot to get uplifted.
reopening for landing into NSPR and fixing the target milestone.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: --- → 4.14
NSPR trunk:
https://hg.mozilla.org/projects/nspr/rev/271a33c4c9a4

Will land into a new NSPR 4.14 branch if things look good.
Blocks: 1347932
4.14 branch:
https://hg.mozilla.org/projects/nspr/rev/643558f3ac5b
Status: REOPENED → RESOLVED
Closed: 7 years ago7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: