mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-09 23:36:04 +00:00
Merge pull request #246 from pieterh/arguments
Return EFAULT if required arguments are null
This commit is contained in:
commit
a457be315b
@ -9,7 +9,7 @@ zmq_msg_size - retrieve message content size in bytes
|
|||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
*size_t zmq_msg_size (zmq_msg_t '*msg');*
|
*ssize_t zmq_msg_size (zmq_msg_t '*msg');*
|
||||||
|
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
@ -29,7 +29,15 @@ message content in bytes.
|
|||||||
|
|
||||||
ERRORS
|
ERRORS
|
||||||
------
|
------
|
||||||
No errors are defined.
|
The _zmq_msg_size()_ function shall return a positive integer (0 or higher)
|
||||||
|
if successful. Otherwise it shall return `-1` and set 'errno' to one of the
|
||||||
|
values defined below.
|
||||||
|
|
||||||
|
|
||||||
|
ERRORS
|
||||||
|
------
|
||||||
|
*EFAULT*::
|
||||||
|
The provided 'msg' was NULL.
|
||||||
|
|
||||||
|
|
||||||
SEE ALSO
|
SEE ALSO
|
||||||
@ -44,5 +52,5 @@ linkzmq:zmq[7]
|
|||||||
|
|
||||||
AUTHORS
|
AUTHORS
|
||||||
-------
|
-------
|
||||||
This 0MQ manual page was written by Martin Sustrik <sustrik@250bpm.com> and
|
This 0MQ manual page was written by Martin Sustrik <sustrik@250bpm.com>,
|
||||||
Martin Lucina <mato@kotelna.sk>.
|
Martin Lucina <mato@kotelna.sk>, and Pieter Hintjens <ph@imatix.com>.
|
||||||
|
@ -29,6 +29,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
#if defined _WIN32
|
#if defined _WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#endif
|
#endif
|
||||||
@ -167,14 +168,13 @@ ZMQ_EXPORT int zmq_msg_close (zmq_msg_t *msg);
|
|||||||
ZMQ_EXPORT int zmq_msg_move (zmq_msg_t *dest, zmq_msg_t *src);
|
ZMQ_EXPORT int zmq_msg_move (zmq_msg_t *dest, zmq_msg_t *src);
|
||||||
ZMQ_EXPORT int zmq_msg_copy (zmq_msg_t *dest, zmq_msg_t *src);
|
ZMQ_EXPORT int zmq_msg_copy (zmq_msg_t *dest, zmq_msg_t *src);
|
||||||
ZMQ_EXPORT void *zmq_msg_data (zmq_msg_t *msg);
|
ZMQ_EXPORT void *zmq_msg_data (zmq_msg_t *msg);
|
||||||
ZMQ_EXPORT size_t zmq_msg_size (zmq_msg_t *msg);
|
ZMQ_EXPORT ssize_t zmq_msg_size (zmq_msg_t *msg);
|
||||||
ZMQ_EXPORT int zmq_msg_more (zmq_msg_t *msg);
|
ZMQ_EXPORT int zmq_msg_more (zmq_msg_t *msg);
|
||||||
ZMQ_EXPORT int zmq_msg_get (zmq_msg_t *msg, int option, void *optval,
|
ZMQ_EXPORT int zmq_msg_get (zmq_msg_t *msg, int option, void *optval,
|
||||||
size_t *optvallen);
|
size_t *optvallen);
|
||||||
ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int option, const void *optval,
|
ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int option, const void *optval,
|
||||||
size_t *optvallen);
|
size_t *optvallen);
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* 0MQ infrastructure (a.k.a. context) initialisation & termination. */
|
/* 0MQ infrastructure (a.k.a. context) initialisation & termination. */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
Copyright (c) 2007-2012 iMatix Corporation
|
||||||
Copyright (c) 2009-2011 250bpm s.r.o.
|
Copyright (c) 2009-2011 250bpm s.r.o.
|
||||||
Copyright (c) 2007-2009 iMatix Corporation
|
|
||||||
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
|
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
|
||||||
|
|
||||||
This file is part of 0MQ.
|
This file is part of 0MQ.
|
||||||
@ -35,7 +35,7 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static size_t message_size;
|
static ssize_t message_size;
|
||||||
static int roundtrip_count;
|
static int roundtrip_count;
|
||||||
|
|
||||||
#if defined ZMQ_HAVE_WINDOWS
|
#if defined ZMQ_HAVE_WINDOWS
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
Copyright (c) 2007-2012 iMatix Corporation
|
||||||
Copyright (c) 2009-2011 250bpm s.r.o.
|
Copyright (c) 2009-2011 250bpm s.r.o.
|
||||||
Copyright (c) 2007-2009 iMatix Corporation
|
|
||||||
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
|
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
|
||||||
|
|
||||||
This file is part of 0MQ.
|
This file is part of 0MQ.
|
||||||
@ -36,7 +36,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int message_count;
|
static int message_count;
|
||||||
static size_t message_size;
|
static ssize_t message_size;
|
||||||
|
|
||||||
#if defined ZMQ_HAVE_WINDOWS
|
#if defined ZMQ_HAVE_WINDOWS
|
||||||
static unsigned int __stdcall worker (void *ctx_)
|
static unsigned int __stdcall worker (void *ctx_)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
Copyright (c) 2007-2012 iMatix Corporation
|
||||||
Copyright (c) 2009-2011 250bpm s.r.o.
|
Copyright (c) 2009-2011 250bpm s.r.o.
|
||||||
Copyright (c) 2007-2009 iMatix Corporation
|
|
||||||
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
|
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
|
||||||
|
|
||||||
This file is part of 0MQ.
|
This file is part of 0MQ.
|
||||||
@ -28,7 +28,7 @@ int main (int argc, char *argv [])
|
|||||||
{
|
{
|
||||||
const char *bind_to;
|
const char *bind_to;
|
||||||
int roundtrip_count;
|
int roundtrip_count;
|
||||||
size_t message_size;
|
ssize_t message_size;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
void *s;
|
void *s;
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
Copyright (c) 2007-2012 iMatix Corporation
|
||||||
Copyright (c) 2009-2011 250bpm s.r.o.
|
Copyright (c) 2009-2011 250bpm s.r.o.
|
||||||
Copyright (c) 2007-2009 iMatix Corporation
|
|
||||||
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
|
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
|
||||||
|
|
||||||
This file is part of 0MQ.
|
This file is part of 0MQ.
|
||||||
@ -28,7 +28,7 @@ int main (int argc, char *argv [])
|
|||||||
{
|
{
|
||||||
const char *bind_to;
|
const char *bind_to;
|
||||||
int message_count;
|
int message_count;
|
||||||
size_t message_size;
|
ssize_t message_size;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
void *s;
|
void *s;
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
Copyright (c) 2007-2012 iMatix Corporation
|
||||||
Copyright (c) 2009-2011 250bpm s.r.o.
|
Copyright (c) 2009-2011 250bpm s.r.o.
|
||||||
Copyright (c) 2007-2009 iMatix Corporation
|
|
||||||
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
|
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
|
||||||
|
|
||||||
This file is part of 0MQ.
|
This file is part of 0MQ.
|
||||||
@ -29,7 +29,7 @@ int main (int argc, char *argv [])
|
|||||||
{
|
{
|
||||||
const char *connect_to;
|
const char *connect_to;
|
||||||
int roundtrip_count;
|
int roundtrip_count;
|
||||||
size_t message_size;
|
ssize_t message_size;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
void *s;
|
void *s;
|
||||||
int rc;
|
int rc;
|
||||||
|
44
src/zmq.cpp
44
src/zmq.cpp
@ -502,17 +502,29 @@ int zmq_recviov (void *s_, iovec *a_, size_t *count_, int flags_)
|
|||||||
|
|
||||||
int zmq_msg_init (zmq_msg_t *msg_)
|
int zmq_msg_init (zmq_msg_t *msg_)
|
||||||
{
|
{
|
||||||
|
if (!msg_) {
|
||||||
|
errno = EFAULT;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return ((zmq::msg_t*) msg_)->init ();
|
return ((zmq::msg_t*) msg_)->init ();
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmq_msg_init_size (zmq_msg_t *msg_, size_t size_)
|
int zmq_msg_init_size (zmq_msg_t *msg_, size_t size_)
|
||||||
{
|
{
|
||||||
|
if (!msg_) {
|
||||||
|
errno = EFAULT;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return ((zmq::msg_t*) msg_)->init_size (size_);
|
return ((zmq::msg_t*) msg_)->init_size (size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmq_msg_init_data (zmq_msg_t *msg_, void *data_, size_t size_,
|
int zmq_msg_init_data (zmq_msg_t *msg_, void *data_, size_t size_,
|
||||||
zmq_free_fn *ffn_, void *hint_)
|
zmq_free_fn *ffn_, void *hint_)
|
||||||
{
|
{
|
||||||
|
if (!msg_) {
|
||||||
|
errno = EFAULT;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return ((zmq::msg_t*) msg_)->init_data (data_, size_, ffn_, hint_);
|
return ((zmq::msg_t*) msg_)->init_data (data_, size_, ffn_, hint_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,26 +556,46 @@ int zmq_msg_recv (zmq_msg_t *msg_, void *s_, int flags_)
|
|||||||
|
|
||||||
int zmq_msg_close (zmq_msg_t *msg_)
|
int zmq_msg_close (zmq_msg_t *msg_)
|
||||||
{
|
{
|
||||||
|
if (!msg_) {
|
||||||
|
errno = EFAULT;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return ((zmq::msg_t*) msg_)->close ();
|
return ((zmq::msg_t*) msg_)->close ();
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmq_msg_move (zmq_msg_t *dest_, zmq_msg_t *src_)
|
int zmq_msg_move (zmq_msg_t *dest_, zmq_msg_t *src_)
|
||||||
{
|
{
|
||||||
|
if (!dest_ || !src_) {
|
||||||
|
errno = EFAULT;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return ((zmq::msg_t*) dest_)->move (*(zmq::msg_t*) src_);
|
return ((zmq::msg_t*) dest_)->move (*(zmq::msg_t*) src_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmq_msg_copy (zmq_msg_t *dest_, zmq_msg_t *src_)
|
int zmq_msg_copy (zmq_msg_t *dest_, zmq_msg_t *src_)
|
||||||
{
|
{
|
||||||
|
if (!dest_ || !src_) {
|
||||||
|
errno = EFAULT;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return ((zmq::msg_t*) dest_)->copy (*(zmq::msg_t*) src_);
|
return ((zmq::msg_t*) dest_)->copy (*(zmq::msg_t*) src_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *zmq_msg_data (zmq_msg_t *msg_)
|
void *zmq_msg_data (zmq_msg_t *msg_)
|
||||||
{
|
{
|
||||||
|
if (!msg_) {
|
||||||
|
errno = EFAULT;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return ((zmq::msg_t*) msg_)->data ();
|
return ((zmq::msg_t*) msg_)->data ();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t zmq_msg_size (zmq_msg_t *msg_)
|
ssize_t zmq_msg_size (zmq_msg_t *msg_)
|
||||||
{
|
{
|
||||||
|
if (!msg_) {
|
||||||
|
errno = EFAULT;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return ((zmq::msg_t*) msg_)->size ();
|
return ((zmq::msg_t*) msg_)->size ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,6 +647,10 @@ int zmq_msg_set (zmq_msg_t *msg_, int option_, const void *optval_,
|
|||||||
|
|
||||||
int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
|
int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
|
||||||
{
|
{
|
||||||
|
if (!items_) {
|
||||||
|
errno = EFAULT;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
#if defined ZMQ_POLL_BASED_ON_POLL
|
#if defined ZMQ_POLL_BASED_ON_POLL
|
||||||
if (unlikely (nitems_ < 0)) {
|
if (unlikely (nitems_ < 0)) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
@ -633,12 +669,6 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
|
|||||||
return usleep (timeout_ * 1000);
|
return usleep (timeout_ * 1000);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!items_) {
|
|
||||||
errno = EFAULT;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
zmq::clock_t clock;
|
zmq::clock_t clock;
|
||||||
uint64_t now = 0;
|
uint64_t now = 0;
|
||||||
uint64_t end = 0;
|
uint64_t end = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user