From 739a112becd12b85b2c5a184a1c9a8e8e4c45909 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 6 Apr 2017 18:42:54 -0400 Subject: [PATCH] db: dbGet() ensure long string nil and actual string length --- src/ioc/db/dbAccess.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ioc/db/dbAccess.c b/src/ioc/db/dbAccess.c index 97e9c9ad4..4b232b37e 100644 --- a/src/ioc/db/dbAccess.c +++ b/src/ioc/db/dbAccess.c @@ -942,6 +942,15 @@ long dbGet(DBADDR *paddr, short dbrType, localAddr.pfield = (char *) pfl->u.r.field; status = convert(&localAddr, pbuf, n, capacity, offset); } + + if(!status && dbrType==DBF_CHAR && nRequest && + paddr->pfldDes && paddr->pfldDes->field_type==DBF_STRING) + { + /* long string ensure nil and truncate to actual length */ + long nReq = *nRequest; + pbuf[nReq-1] = '\0'; + *nRequest = strlen(pbuf)+1; + } } done: paddr->pfield = pfieldsave;