From: Sage Weil Date: Sat, 8 Nov 2014 01:10:18 +0000 (-0800) Subject: librados: EINVAL on bad args to watch2 X-Git-Tag: v0.91~130 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e0e90f71e4e3aaca5813e82975e7aefe5235bf9f;p=ceph.git librados: EINVAL on bad args to watch2 Signed-off-by: Sage Weil --- diff --git a/src/librados/librados.cc b/src/librados/librados.cc index b86b008f3547..7f7fd10ae531 100644 --- a/src/librados/librados.cc +++ b/src/librados/librados.cc @@ -3794,12 +3794,17 @@ extern "C" int rados_watch2(rados_ioctx_t io, const char *o, uint64_t *handle, void *arg) { tracepoint(librados, rados_watch2_enter, io, o, handle, watchcb, arg); - uint64_t *cookie = handle; - librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io; - object_t oid(o); - C_WatchCB2 *wc = new C_WatchCB2(watchcb, watcherrcb, arg); - int ret = ctx->watch(oid, cookie, NULL, wc); - tracepoint(librados, rados_watch_exit, ret, *handle); + int ret; + if (!watchcb || !o || !handle) { + ret = -EINVAL; + } else { + uint64_t *cookie = handle; + librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io; + object_t oid(o); + C_WatchCB2 *wc = new C_WatchCB2(watchcb, watcherrcb, arg); + ret = ctx->watch(oid, cookie, NULL, wc); + } + tracepoint(librados, rados_watch_exit, ret, handle ? *handle : 0); return ret; }