tsocket: return EINVAL when tdgram_sendto_send() is used with len == 0
authorStefan Metzmacher <metze@samba.org>
Fri, 10 Apr 2009 18:35:12 +0000 (20:35 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 1 May 2009 15:38:23 +0000 (17:38 +0200)
metze

lib/tsocket/tsocket.c

index 8e97997d8582c5aca0e370f86ffbc4f032a9ccf6..11ae6ce9ed194ec863ec0cf161fe8536fa889102 100644 (file)
@@ -219,6 +219,11 @@ struct tevent_req *tdgram_sendto_send(TALLOC_CTX *mem_ctx,
        state->ops = dgram->ops;
        state->ret = -1;
 
        state->ops = dgram->ops;
        state->ret = -1;
 
+       if (len == 0) {
+               tevent_req_error(req, EINVAL);
+               goto post;
+       }
+
        subreq = state->ops->sendto_send(state, ev, dgram,
                                         buf, len, dst);
        if (tevent_req_nomem(subreq, req)) {
        subreq = state->ops->sendto_send(state, ev, dgram,
                                         buf, len, dst);
        if (tevent_req_nomem(subreq, req)) {