|
1 # This patch addresses a few issues in the dynafile actions for omfiles. |
|
2 # Specifcally if the target file cannot be opened, rsyslogd will segfault. |
|
3 # The patch is from an upstream pull: |
|
4 # https://github.com/rsyslog/rsyslog/pull/450/commits |
|
5 # and should be removed when rsyslog is moved to or past version 8.12.0 |
|
6 |
|
7 --- rsyslog/runtime/srutils.c.1 Wed Nov 25 10:48:03 2015 |
|
8 +++ rsyslog/runtime/srutils.c Wed Nov 25 10:49:05 2015 |
|
9 @@ -198,7 +198,6 @@ |
|
10 uchar *p; |
|
11 uchar *pszWork; |
|
12 size_t len; |
|
13 - int err; |
|
14 int iTry = 0; |
|
15 int bErr = 0; |
|
16 |
|
17 @@ -215,7 +214,7 @@ |
|
18 *p = '\0'; |
|
19 again: |
|
20 if(access((char*)pszWork, F_OK)) { |
|
21 - if((err = mkdir((char*)pszWork, mode)) == 0) { |
|
22 + if(mkdir((char*)pszWork, mode) == 0) { |
|
23 if(uid != (uid_t) -1 || gid != (gid_t) -1) { |
|
24 /* we need to set owner/group */ |
|
25 if(chown((char*)pszWork, uid, gid) != 0) |
|
26 @@ -226,7 +225,7 @@ |
|
27 */ |
|
28 } |
|
29 } else { |
|
30 - if(err == EEXIST && iTry == 0) { |
|
31 + if(errno == EEXIST && iTry == 0) { |
|
32 iTry = 1; |
|
33 goto again; |
|
34 } |
|
35 --- rsyslog/tools/omfile.c.1 Wed Nov 25 10:39:15 2015 |
|
36 +++ rsyslog/tools/omfile.c Wed Nov 25 10:47:18 2015 |
|
37 @@ -723,12 +723,6 @@ |
|
38 /* we have not found an entry */ |
|
39 STATSCOUNTER_INC(pData->ctrMiss, pData->mutCtrMiss); |
|
40 |
|
41 - /* invalidate iCurrElt as we may error-exit out of this function when the currrent |
|
42 - * iCurrElt has been freed or otherwise become unusable. This is a precaution, and |
|
43 - * performance-wise it may be better to do that in each of the exits. However, that |
|
44 - * is error-prone, so I prefer to do it here. -- rgerhards, 2010-03-02 |
|
45 - */ |
|
46 - pData->iCurrElt = -1; |
|
47 /* similarly, we need to set the current pStrm to NULL, because otherwise, if prepareFile() fails, |
|
48 * we may end up using an old stream. This bug depends on how exactly prepareFile fails, |
|
49 * but it could be triggered in the common case of a failed open() system call. |
|
50 @@ -779,7 +773,8 @@ |
|
51 DBGPRINTF("Added new entry %d for file cache, file '%s'.\n", iFirstFree, newFileName); |
|
52 |
|
53 finalize_it: |
|
54 - pCache[pData->iCurrElt]->nInactive = 0; |
|
55 + if(iRet == RS_RET_OK) |
|
56 + pCache[pData->iCurrElt]->nInactive = 0; |
|
57 RETiRet; |
|
58 } |
|
59 |