Several months ago it was pointed out to me that dbPutString in src/dbStatic/dbStaticLib.c uses a fixed length buffer when processing Link strings. This buffer is defined as 'char string[80];'. This is apparently the limit on the length of a string which can be passed to device support. In this particular case the issue was a device support for accessing SNMP which apparently can have some really long names.
Attached is a patch which replaces this with a dynamically allocated string buffer. I originally avoided doing the allocation, but the result had some strange string manipulations which seem ripe for off-by-one errors. I can't quite bring myself to submit it.
I'm not certain if this is the correct solutions, but here it is.
Michael
From 1ddc3f7c92e49a62ee54caa70e780ad2d65d2a4a Mon Sep 17 00:00:00 2001
From: Michael Davidsaver <[email protected]>
Date: Wed, 16 Dec 2009 11:51:57 -0500
Subject: dbPutString: Don't use a fixed length string buffer
---
src/dbStatic/dbStaticLib.c | 11 ++---------
1 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/src/dbStatic/dbStaticLib.c b/src/dbStatic/dbStaticLib.c
index 47d75b7..39c743f 100644
--- a/src/dbStatic/dbStaticLib.c
+++ b/src/dbStatic/dbStaticLib.c
@@ -2202,8 +2202,7 @@ long epicsShareAPI dbPutString(DBENTRY *pdbentry,const char *pstring)
case DBF_OUTLINK:
case DBF_FWDLINK: {
DBLINK *plink;
- char string[80];
- char *pstr = string;
+ char *pstr = NULL;
int ind;
if (!pfield)
@@ -2225,13 +2224,7 @@ long epicsShareAPI dbPutString(DBENTRY *pdbentry,const char *pstring)
return status;
}
}
- if (strlen(pstring) >= sizeof(string)) {
- status = S_dbLib_badField;
- errMessage(status,
- "dbPutString received a string that is too long");
- return status;
- }
- strcpy(pstr, pstring);
+ pstr=epicsStrDup(pstring);
/* Strip leading blanks and tabs */
while (*pstr && (*pstr == ' ' || *pstr == '\t')) pstr++;
/* Strip trailing blanks and tabs */
--
1.6.3.3
- Navigate by Date:
- Prev:
RE: multiple NTP servers and NTPTime Kalantari Babak
- Next:
CVS migration to Bazaar Andrew Johnson
- Index:
2002
2003
2004
2005
2006
2007
2008
<2009>
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
RE: multiple NTP servers and NTPTime Kalantari Babak
- Next:
CVS migration to Bazaar Andrew Johnson
- Index:
2002
2003
2004
2005
2006
2007
2008
<2009>
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|