From 46270ba3543c22cf68bf024c691d139fe21c3e61 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Mon, 14 May 2012 23:13:08 -0400 Subject: [PATCH] handle binding port 0. --- mbind.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mbind.c b/mbind.c index b18bc6f..5db5de6 100644 --- a/mbind.c +++ b/mbind.c @@ -56,10 +56,19 @@ int mbind(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5) // address component is ignored -- only port is used. - IncBusy(); - TCPIPSetSourcePort(e->ipid, port); - DecBusy(); + // bind w/ port 0 means the system should pick a port. + // marinetti picks a port at TCPIPLogin time, so no need + // to do anything here. + // Note: TCPIPSetSourcePort does not check if the port is free. + + // todo -- return EACCES if reserved port && !root. + if (port) + { + IncBusy(); + TCPIPSetSourcePort(e->ipid, port); + DecBusy(); + } return 0; } \ No newline at end of file