From 9c3ed1bfe20ab4f9e3beda32791ba0e48025375c Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Thu, 26 May 2016 13:13:29 +0200 Subject: [PATCH] catools: fix escape handling when sending long strings --- src/catools/caput.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/catools/caput.c b/src/catools/caput.c index 9e1adcd46..02182932d 100644 --- a/src/catools/caput.c +++ b/src/catools/caput.c @@ -490,14 +490,13 @@ int main (int argc, char *argv[]) } else { /* Not an ENUM */ if (charArrAsStr) { - count = len; dbrType = DBR_CHAR; - ebuf = calloc(strlen(cbuf)+1, sizeof(char)); + ebuf = calloc(len, sizeof(char)); if(!ebuf) { fprintf(stderr, "Memory allocation failed\n"); return 1; } - epicsStrnRawFromEscaped(ebuf, strlen(cbuf)+1, cbuf, strlen(cbuf)); + count = epicsStrnRawFromEscaped(ebuf, len, cbuf, len-1) + 1; } else { for (i = 0; i < count; ++i) { epicsStrnRawFromEscaped(sbuf[i], sizeof(EpicsStr), *(argv+optind+i), sizeof(EpicsStr));