/[pkg-src]/trunk/systemd/patches/systemd-38-tmpfiles-fix-parsing-of-proc-net-unix-on-32Bit-machines.patch |
Contents of /trunk/systemd/patches/systemd-38-tmpfiles-fix-parsing-of-proc-net-unix-on-32Bit-machines.patch
Parent Directory | Revision Log
Revision 1624 -
(show annotations)
(download)
Thu Jan 19 23:11:04 2012 UTC (12 years, 8 months ago) by niro
File size: 2673 byte(s)
Thu Jan 19 23:11:04 2012 UTC (12 years, 8 months ago) by niro
File size: 2673 byte(s)
-upstream fixes
1 | From fdcad0c25579a60061b1fda956686e878a80faef Mon Sep 17 00:00:00 2001 |
2 | From: Lennart Poettering <lennart@poettering.net> |
3 | Date: Wed, 11 Jan 2012 22:07:35 +0100 |
4 | Subject: [PATCH] tmpfiles: fix parsing of /proc/net/unix on 32Bit machines |
5 | |
6 | Tracked down by Michael Meeks |
7 | --- |
8 | src/tmpfiles.c | 30 ++++++++++++++++++++---------- |
9 | 1 files changed, 20 insertions(+), 10 deletions(-) |
10 | |
11 | diff --git a/src/tmpfiles.c b/src/tmpfiles.c |
12 | index 19a7c08..44e5c9d 100644 |
13 | --- a/src/tmpfiles.c |
14 | +++ b/src/tmpfiles.c |
15 | @@ -117,41 +117,50 @@ static void load_unix_sockets(void) { |
16 | /* We maintain a cache of the sockets we found in |
17 | * /proc/net/unix to speed things up a little. */ |
18 | |
19 | - if (!(unix_sockets = set_new(string_hash_func, string_compare_func))) |
20 | + unix_sockets = set_new(string_hash_func, string_compare_func); |
21 | + if (!unix_sockets) |
22 | return; |
23 | |
24 | - if (!(f = fopen("/proc/net/unix", "re"))) |
25 | + f = fopen("/proc/net/unix", "re"); |
26 | + if (!f) |
27 | return; |
28 | |
29 | - if (!(fgets(line, sizeof(line), f))) |
30 | + /* Skip header */ |
31 | + if (!fgets(line, sizeof(line), f)) |
32 | goto fail; |
33 | |
34 | for (;;) { |
35 | char *p, *s; |
36 | int k; |
37 | |
38 | - if (!(fgets(line, sizeof(line), f))) |
39 | + if (!fgets(line, sizeof(line), f)) |
40 | break; |
41 | |
42 | truncate_nl(line); |
43 | |
44 | - if (strlen(line) < 53) |
45 | + p = strchr(line, ':'); |
46 | + if (!p) |
47 | + continue; |
48 | + |
49 | + if (strlen(p) < 37) |
50 | continue; |
51 | |
52 | - p = line + 53; |
53 | + p += 37; |
54 | p += strspn(p, WHITESPACE); |
55 | - p += strcspn(p, WHITESPACE); |
56 | + p += strcspn(p, WHITESPACE); /* skip one more word */ |
57 | p += strspn(p, WHITESPACE); |
58 | |
59 | if (*p != '/') |
60 | continue; |
61 | |
62 | - if (!(s = strdup(p))) |
63 | + s = strdup(p); |
64 | + if (!s) |
65 | goto fail; |
66 | |
67 | path_kill_slashes(s); |
68 | |
69 | - if ((k = set_put(unix_sockets, s)) < 0) { |
70 | + k = set_put(unix_sockets, s); |
71 | + if (k < 0) { |
72 | free(s); |
73 | |
74 | if (k != -EEXIST) |
75 | @@ -1059,7 +1068,8 @@ int main(int argc, char *argv[]) { |
76 | Item *i; |
77 | Iterator iterator; |
78 | |
79 | - if ((r = parse_argv(argc, argv)) <= 0) |
80 | + r = parse_argv(argc, argv); |
81 | + if (r <= 0) |
82 | return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; |
83 | |
84 | log_set_target(LOG_TARGET_AUTO); |
85 | -- |
86 | 1.7.8.3 |