summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-07-24 11:20:21 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-07-24 11:20:21 +0200
commitf043778bdc23c7b2baf18c1fc35ba47fa4d8386c (patch)
treef9b3e7d4970a1db46b414e9f493fb56313f1c9bf
parent8805b0f25ff1409a41ecc2e054896e653e4cfa55 (diff)
downloadrsyslog-f043778bdc23c7b2baf18c1fc35ba47fa4d8386c.tar.gz
rsyslog-f043778bdc23c7b2baf18c1fc35ba47fa4d8386c.tar.xz
rsyslog-f043778bdc23c7b2baf18c1fc35ba47fa4d8386c.zip
bugfix: strm class could abort under some circumstances
... it could pass a NULL pointer to unlink. Depending on OS implementation, this could (or could not...) lead to a segfault.
-rw-r--r--runtime/stream.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/runtime/stream.c b/runtime/stream.c
index 6b88d3f4..bb1a0a42 100644
--- a/runtime/stream.c
+++ b/runtime/stream.c
@@ -16,7 +16,7 @@
* it turns out to be problematic. Then, we need to quasi-refcount the number of accesses
* to the object.
*
- * Copyright 2008, 2009 Rainer Gerhards and Adiscon GmbH.
+ * Copyright 2008-2012 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@@ -361,7 +361,7 @@ static rsRetVal strmCloseFile(strm_t *pThis)
pThis->fdDir = -1;
}
- if(pThis->bDeleteOnClose) {
+ if(pThis->bDeleteOnClose && pThis->pszCurrFName != NULL) {
if(unlink((char*) pThis->pszCurrFName) == -1) {
char errStr[1024];
int err = errno;
@@ -369,14 +369,12 @@ static rsRetVal strmCloseFile(strm_t *pThis)
DBGPRINTF("error %d unlinking '%s' - ignored: %s\n",
errno, pThis->pszCurrFName, errStr);
}
- }
-
- pThis->iCurrOffs = 0; /* we are back at begin of file */
- if(pThis->pszCurrFName != NULL) {
free(pThis->pszCurrFName); /* no longer needed in any case (just for open) */
pThis->pszCurrFName = NULL;
}
+ pThis->iCurrOffs = 0; /* we are back at begin of file */
+
RETiRet;
}