diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-07-03 16:30:32 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-07-10 00:55:35 +0000 |
commit | f56b866f92e195ffd24a2f8f80e8e2cef226c775 (patch) | |
tree | c7bf4db205273aadc4721e8234c7a1864af03a24 | |
parent | 5027df50b5072d964f551414e259c2903778ea36 (diff) | |
download | cmogstored-f56b866f92e195ffd24a2f8f80e8e2cef226c775.tar.gz |
mgmt: fix case where rbuf->rsize may be uninitialized
Detachers MUST set rsize properly. This API is unfortunately fragile and will eventually be fixed to be more difficult to misuse.
-rw-r--r-- | alloc.c | 5 | ||||
-rw-r--r-- | mgmt.c | 7 |
2 files changed, 10 insertions, 2 deletions
@@ -102,6 +102,11 @@ struct mog_rbuf *mog_rbuf_new(size_t size) else rbuf = xmalloc(bytes); rbuf->rcapa = size; + /* + * do not initialize rsize here, we only need rsize when we detach + * a TLS rbuf and associate it with a mog_fd, not in the common + * case where the rbuf remains thread-local + */ return rbuf; } @@ -221,8 +221,11 @@ parse: } else { switch (errno) { case_EAGAIN: - if ((buf_len > 0) && (mgmt->rbuf == NULL)) - mgmt->rbuf = mog_rbuf_detach(rbuf); + if (buf_len > 0) { + if (mgmt->rbuf == NULL) + mgmt->rbuf = mog_rbuf_detach(rbuf); + mgmt->rbuf->rsize = buf_len; + } return MOG_NEXT_WAIT_RD; case EINTR: goto reread; case ECONNRESET: |