|
@@ -456,6 +456,12 @@ static int tcp_connect (PAL_HANDLE * handle, char * uri, int options)
|
|
|
static int tcp_open (PAL_HANDLE *handle, const char * type, const char * uri,
|
|
|
int access, int share, int create, int options)
|
|
|
{
|
|
|
+ if (!WITHIN_MASK(access, PAL_ACCESS_MASK) ||
|
|
|
+ !WITHIN_MASK(share, PAL_SHARE_MASK) ||
|
|
|
+ !WITHIN_MASK(create, PAL_CREATE_MASK) ||
|
|
|
+ !WITHIN_MASK(options, PAL_OPTION_MASK))
|
|
|
+ return -PAL_ERROR_INVAL;
|
|
|
+
|
|
|
int uri_len = strlen(uri) + 1;
|
|
|
|
|
|
if (uri_len > PAL_SOCKADDR_SIZE)
|
|
@@ -477,6 +483,9 @@ static int tcp_open (PAL_HANDLE *handle, const char * type, const char * uri,
|
|
|
static int64_t tcp_read (PAL_HANDLE handle, uint64_t offset, uint64_t len,
|
|
|
void * buf)
|
|
|
{
|
|
|
+ if (offset)
|
|
|
+ return -PAL_ERROR_INVAL;
|
|
|
+
|
|
|
if (!IS_HANDLE_TYPE(handle, tcp) || !handle->sock.conn)
|
|
|
return -PAL_ERROR_NOTCONNECTION;
|
|
|
|
|
@@ -501,6 +510,9 @@ static int64_t tcp_read (PAL_HANDLE handle, uint64_t offset, uint64_t len,
|
|
|
static int64_t tcp_write (PAL_HANDLE handle, uint64_t offset, uint64_t len,
|
|
|
const void * buf)
|
|
|
{
|
|
|
+ if (offset)
|
|
|
+ return -PAL_ERROR_INVAL;
|
|
|
+
|
|
|
if (!IS_HANDLE_TYPE(handle, tcp) || !handle->sock.conn)
|
|
|
return -PAL_ERROR_NOTCONNECTION;
|
|
|
|
|
@@ -611,6 +623,12 @@ static int udp_connect (PAL_HANDLE * handle, char * uri, int options)
|
|
|
static int udp_open (PAL_HANDLE *hdl, const char * type, const char * uri,
|
|
|
int access, int share, int create, int options)
|
|
|
{
|
|
|
+ if (!WITHIN_MASK(access, PAL_ACCESS_MASK) ||
|
|
|
+ !WITHIN_MASK(share, PAL_SHARE_MASK) ||
|
|
|
+ !WITHIN_MASK(create, PAL_CREATE_MASK) ||
|
|
|
+ !WITHIN_MASK(options, PAL_OPTION_MASK))
|
|
|
+ return -PAL_ERROR_INVAL;
|
|
|
+
|
|
|
char buf[PAL_SOCKADDR_SIZE];
|
|
|
int len = strlen(uri);
|
|
|
|
|
@@ -618,7 +636,6 @@ static int udp_open (PAL_HANDLE *hdl, const char * type, const char * uri,
|
|
|
return -PAL_ERROR_TOOLONG;
|
|
|
|
|
|
memcpy(buf, uri, len + 1);
|
|
|
- options &= PAL_OPTION_MASK;
|
|
|
|
|
|
if (strcmp_static(type, "udp.srv"))
|
|
|
return udp_bind(hdl, buf, options);
|
|
@@ -632,6 +649,9 @@ static int udp_open (PAL_HANDLE *hdl, const char * type, const char * uri,
|
|
|
static int64_t udp_receive (PAL_HANDLE handle, uint64_t offset, uint64_t len,
|
|
|
void * buf)
|
|
|
{
|
|
|
+ if (offset)
|
|
|
+ return -PAL_ERROR_INVAL;
|
|
|
+
|
|
|
if (!IS_HANDLE_TYPE(handle, udp))
|
|
|
return -PAL_ERROR_NOTCONNECTION;
|
|
|
|
|
@@ -647,6 +667,9 @@ static int64_t udp_receive (PAL_HANDLE handle, uint64_t offset, uint64_t len,
|
|
|
static int64_t udp_receivebyaddr (PAL_HANDLE handle, uint64_t offset, uint64_t len,
|
|
|
void * buf, char * addr, int addrlen)
|
|
|
{
|
|
|
+ if (offset)
|
|
|
+ return -PAL_ERROR_INVAL;
|
|
|
+
|
|
|
if (!IS_HANDLE_TYPE(handle, udpsrv))
|
|
|
return -PAL_ERROR_NOTCONNECTION;
|
|
|
|
|
@@ -680,6 +703,9 @@ static int64_t udp_receivebyaddr (PAL_HANDLE handle, uint64_t offset, uint64_t l
|
|
|
static int64_t udp_send (PAL_HANDLE handle, uint64_t offset, uint64_t len,
|
|
|
const void * buf)
|
|
|
{
|
|
|
+ if (offset)
|
|
|
+ return -PAL_ERROR_INVAL;
|
|
|
+
|
|
|
if (!IS_HANDLE_TYPE(handle, udp))
|
|
|
return -PAL_ERROR_NOTCONNECTION;
|
|
|
|
|
@@ -708,6 +734,9 @@ static int64_t udp_send (PAL_HANDLE handle, uint64_t offset, uint64_t len,
|
|
|
static int64_t udp_sendbyaddr (PAL_HANDLE handle, uint64_t offset, uint64_t len,
|
|
|
const void * buf, const char * addr, int addrlen)
|
|
|
{
|
|
|
+ if (offset)
|
|
|
+ return -PAL_ERROR_INVAL;
|
|
|
+
|
|
|
if (!IS_HANDLE_TYPE(handle, udpsrv))
|
|
|
return -PAL_ERROR_NOTCONNECTION;
|
|
|
|
|
@@ -1061,6 +1090,9 @@ PAL_HANDLE _DkBroadcastStreamOpen (void)
|
|
|
static int64_t mcast_send (PAL_HANDLE handle, uint64_t offset, uint64_t size,
|
|
|
const void * buf)
|
|
|
{
|
|
|
+ if (offset)
|
|
|
+ return -PAL_ERROR_INVAL;
|
|
|
+
|
|
|
if (handle->mcast.srv == PAL_IDX_POISON)
|
|
|
return -PAL_ERROR_BADHANDLE;
|
|
|
|
|
@@ -1087,6 +1119,9 @@ static int64_t mcast_send (PAL_HANDLE handle, uint64_t offset, uint64_t size,
|
|
|
static int64_t mcast_receive (PAL_HANDLE handle, uint64_t offset, uint64_t size,
|
|
|
void * buf)
|
|
|
{
|
|
|
+ if (offset)
|
|
|
+ return -PAL_ERROR_INVAL;
|
|
|
+
|
|
|
if (handle->mcast.cli == PAL_IDX_POISON)
|
|
|
return -PAL_ERROR_BADHANDLE;
|
|
|
|