summaryrefslogtreecommitdiffstats
path: root/backend_dnpds40.c
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-01-22 23:59:22 -0500
committerSolomon Peachy <pizza@shaftnet.org>2020-01-23 00:06:01 -0500
commit4cb5de95582f140f1f59da61214cdfe61c55c996 (patch)
treee342b6ee85fed9d238a88a549db1d37b5c91dbd3 /backend_dnpds40.c
parent41817d15c84f60137a6349cc6b55ef55fc10b39e (diff)
downloadselphy_print-4cb5de95582f140f1f59da61214cdfe61c55c996.tar.gz
selphy_print-4cb5de95582f140f1f59da61214cdfe61c55c996.tar.bz2
selphy_print-4cb5de95582f140f1f59da61214cdfe61c55c996.zip
DNP: Explcicitly null-terminate all response buffers.
Since the RX1 doesn't terminate the version string properly..
Diffstat (limited to 'backend_dnpds40.c')
-rw-r--r--backend_dnpds40.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/backend_dnpds40.c b/backend_dnpds40.c
index 26714fc..57de02f 100644
--- a/backend_dnpds40.c
+++ b/backend_dnpds40.c
@@ -343,7 +343,7 @@ static void *dnp_combine_jobs(const void *vjob1,
memset(newjob->databuf + newjob->datalen + i, 0, gap_bytes);
newjob->datalen += gap_bytes;
} else {
- uint8_t *ptrA = newjob->databuf + newjob->datalen + 1088;
+// uint8_t *ptrA = newjob->databuf + newjob->datalen + 1088;
// /* Back off by 1/2 the gap */
// memmove(ptrA, ptrA - (gap_bytes / 2), (i - 1088) + gap_bytes/2);
/* And chop the end off by half the gap */
@@ -650,11 +650,12 @@ static uint8_t *dnpds40_resp_cmd2(struct dnpds40_ctx *ctx,
}
i = atoi(tmp); /* Length of payload in bytes, possibly padded */
- respbuf = malloc(i);
+ respbuf = malloc(i + 1);
if (!respbuf) {
ERROR("Memory allocation failure (%d bytes)!\n", i);
return NULL;
}
+ respbuf[i] = 0; /* Explicitly null-pad */
/* Read in the actual response */
ret = read_data(ctx->dev, ctx->endp_up,