diff -Nru tgt-1.0.43/debian/changelog tgt-1.0.43/debian/changelog --- tgt-1.0.43/debian/changelog 2015-07-21 09:02:51.000000000 -0400 +++ tgt-1.0.43/debian/changelog 2015-09-24 15:31:19.000000000 -0400 @@ -1,3 +1,10 @@ +tgt (1:1.0.43-0ubuntu4.2) vivid; urgency=medium + + * debian/patches/fix-read-response-buffer.patch : Fix bug to read + the response buffer (LP: #1498697) + + -- Eric Desrochers Thu, 24 Sep 2015 15:30:56 -0400 + tgt (1:1.0.43-0ubuntu4.1) vivid; urgency=medium * iSER: Add Discovery support (LP: #1409904) diff -Nru tgt-1.0.43/debian/patches/fix-read-response-buffer.patch tgt-1.0.43/debian/patches/fix-read-response-buffer.patch --- tgt-1.0.43/debian/patches/fix-read-response-buffer.patch 1969-12-31 19:00:00.000000000 -0500 +++ tgt-1.0.43/debian/patches/fix-read-response-buffer.patch 2015-09-24 15:35:00.000000000 -0400 @@ -0,0 +1,60 @@ +Description: fix a bug to read the response buffer + +Signed-off-by: FUJITA Tomonori +--- a/usr/tgtadm.c ++++ b/usr/tgtadm.c +@@ -234,7 +234,8 @@ + static int ipc_mgmt_rsp(int fd, struct tgtadm_req *req) + { + struct tgtadm_rsp rsp; +- int err, rest, len; ++ int err, len, done; ++ char *buf; + + retry: + err = recv(fd, &rsp, sizeof(rsp), MSG_WAITALL); +@@ -278,23 +279,32 @@ + } + } + +- rest = rsp.len - sizeof(rsp); +- if (!rest) ++ len = rsp.len - sizeof(rsp); ++ if (!len) + return 0; + +- while (rest) { +- char buf[BUFSIZE]; +- memset(buf, 0, sizeof(buf)); +- len = min_t(int, sizeof(buf) - 1, rest); +- err = read(fd, buf, len); +- if (err <= 0) { +- eprintf("\ncan't get the full response, %m\n"); +- return errno; ++ buf = malloc(len); ++ if (!buf) { ++ fprintf(stderr, "failed to allocate %d bytes", len); ++ return -ENOMEM; ++ } ++ done = 0; ++ while (len > done) { ++ int ret; ++ ret = read(fd, buf + done, len - done); ++ if (ret < 0) { ++ if (errno == EAGAIN) ++ continue; ++ fprintf(stderr, "failed to read from tgtd, %d", errno); ++ break; + } +- fputs(buf, stdout); +- rest -= len; ++ done += ret; + } + ++ if (done == len) ++ fputs(buf, stdout); ++ free(buf); ++ + return 0; + } + diff -Nru tgt-1.0.43/debian/patches/series tgt-1.0.43/debian/patches/series --- tgt-1.0.43/debian/patches/series 2015-07-21 09:02:49.000000000 -0400 +++ tgt-1.0.43/debian/patches/series 2015-09-24 15:25:20.000000000 -0400 @@ -3,3 +3,4 @@ fix_delayed_management_request.patch fix_leak_of_task_in_scsi_flag.patch add-iser-discovery-support.patch +fix-read-response-buffer.patch