Commit 1fd585e
committed
libselinux: Do not clobber errno of the world
libselinux clobbers errno of all consumers (systemd, sshd you name it)
because its constructors do not properly save and restore errno.
The following program demonstrates it.
int main(void)
{
assert(errno == 0);
/* Just a test, it doesn't matter already clobbered */
if(is_selinux_enabled() < 0) {
perror("not enabled");
return 1;
}
}
if any function sets errno, it is not switched back to the original
value and standards DO NOT require errno to the set to zero before
entering main
Signed-off-by: Cristian Rodríguez <[email protected]>1 parent b411742 commit 1fd585e
2 files changed
+11
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
134 | 144 | | |
0 commit comments