summaryrefslogtreecommitdiffstats
path: root/parse.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-09-05 15:59:47 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-09-05 15:59:47 +0000
commit82aeadce540240396d13d3355d4ef04e3524acbf (patch)
treef2c3372b68174739ed31ed98c52cf6fcce4f9e89 /parse.c
parent0dc7ddd0ea702857c1d5512826e222212b634cb5 (diff)
downloadrsyslog-82aeadce540240396d13d3355d4ef04e3524acbf.tar.gz
rsyslog-82aeadce540240396d13d3355d4ef04e3524acbf.tar.xz
rsyslog-82aeadce540240396d13d3355d4ef04e3524acbf.zip
- changed part of the CStr interface so that better error tracking is
provided and the calling sequence is more intuitive (there were invalid calls based on a too-weired interface) - (hopefully) fixed some remaining bugs rooted in wrong use of the CStr class. These could lead to program abort.
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/parse.c b/parse.c
index efa7f531..9ee16c99 100644
--- a/parse.c
+++ b/parse.c
@@ -361,8 +361,8 @@ rsRetVal parsQuotedCStr(rsParsObj *pThis, rsCStrObj **ppCStr)
#ifdef SYSLOG_INET
rsRetVal parsAddrWithBits(rsParsObj *pThis, struct NetAddr **pIP, int *pBits)
{
- register unsigned char *pC;
- unsigned char *pszIP;
+ register uchar *pC;
+ uchar *pszIP;
uchar *pszTmp;
struct addrinfo hints, *res = NULL;
rsCStrObj *pCStr;
@@ -373,7 +373,7 @@ rsRetVal parsAddrWithBits(rsParsObj *pThis, struct NetAddr **pIP, int *pBits)
assert(pBits != NULL);
if((pCStr = rsCStrConstruct()) == NULL)
- return RS_RET_OUT_OF_MEMORY;
+ ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
parsSkipWhitespace(pThis);
pC = rsCStrGetBufBeg(pThis->pCStr) + pThis->iCurrPos;
@@ -400,11 +400,9 @@ rsRetVal parsAddrWithBits(rsParsObj *pThis, struct NetAddr **pIP, int *pBits)
/* now we have the string and must check/convert it to
* an NetAddr structure.
*/
- if((pszIP = rsCStrConvSzStrAndDestruct(pCStr)) == NULL)
- return RS_RET_ERR;
+ CHKiRet(rsCStrConvSzStrAndDestruct(pCStr, &pszIP, 0));
- *pIP = malloc (sizeof (struct NetAddr));
- memset (*pIP, 0, sizeof (struct NetAddr));
+ *pIP = calloc(1, sizeof(struct NetAddr));
if (*((char*)pszIP) == '[') {
pszTmp = (uchar*)strchr ((char*)pszIP, ']');
@@ -493,7 +491,10 @@ rsRetVal parsAddrWithBits(rsParsObj *pThis, struct NetAddr **pIP, int *pBits)
++pC;
}
- return RS_RET_OK;
+ iRet = RS_RET_OK;
+
+finalize_it:
+ return iRet;
}
#endif /* #ifdef SYSLOG_INET */