X-Git-Url: https://code.grnet.gr/git/archipelago/blobdiff_plain/6d486cc0e4c54f6224e7da47d84b319de3677542..ebee300bfba94ad0b3ba7b7715f8e06f3c142483:/xseg/peers/blockd.c diff --git a/xseg/peers/blockd.c b/xseg/peers/blockd.c index 0bfe05f..730eb4c 100644 --- a/xseg/peers/blockd.c +++ b/xseg/peers/blockd.c @@ -82,9 +82,14 @@ static inline struct io *get_pending_io(struct store *store) static void log_io(char *msg, struct io *io) { char name[64], data[64]; - strncpy(name, io->req->name, 63); - name[63] = 0; - /* strncpy(data, io->req->data, 63); */ + /* null terminate name in case of req->name is less than 63 characters, + * and next character after name (aka first byte of next buffer) is not + * null + */ + unsigned int end = (io->req->namesize > 63) ? 63 : io->req->namesize; + strncpy(name, io->req->name, end); + name[end] = 0; + strncpy(data, io->req->data, 63); data[63] = 0; printf("%s: fd:%u, op:%u %llu:%lu retval: %lu, reqstate: %u\n" "name[%u]:'%s', data[%llu]:\n%s------------------\n\n", @@ -173,7 +178,7 @@ static void handle_read_write(struct store *store, struct io *io) } prepare_io(store, io); - cb->aio_buf = req->data; + cb->aio_buf = req->data + req->serviced; cb->aio_nbytes = req->datasize - req->serviced; cb->aio_offset = req->offset + req->serviced; @@ -375,7 +380,7 @@ malloc_fail: return -1; store->xport = xseg_bind_port(store->xseg, portno); - if (!store->xport) { + if (!store->xport) { printf("cannot bind to port %ld\n", portno); return -1; }