]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/blob
1b972aac292d027770dc3d128c523f5e788b3d15
[thirdparty/openembedded/openembedded-core-contrib.git] /
1 From 70fe022f9dac760eaece0228cad17e3d29a57fb8 Mon Sep 17 00:00:00 2001
2 From: Simon Josefsson <simon@josefsson.org>
3 Date: Mon, 31 Jul 2023 13:59:05 +0200
4 Subject: [PATCH] CVE-2023-40303: Indent changes in previous commit.
5
6 CVE: CVE-2023-40303
7 Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=9122999252c7e21eb7774de11d539748e7bdf46d]
8 Signed-off-by: Khem Raj <raj.khem@gmail.com>
9 ---
10 src/rcp.c | 42 ++++++++++++++++++++++++------------------
11 src/rlogin.c | 12 ++++++------
12 src/rsh.c | 24 ++++++++++++------------
13 src/rshd.c | 24 ++++++++++++------------
14 src/uucpd.c | 16 ++++++++--------
15 5 files changed, 62 insertions(+), 56 deletions(-)
16
17 diff --git a/src/rcp.c b/src/rcp.c
18 index cdcf8500..652f22e6 100644
19 --- a/src/rcp.c
20 +++ b/src/rcp.c
21 @@ -347,9 +347,10 @@ main (int argc, char *argv[])
22 response ();
23
24 if (setuid (userid) == -1)
25 - {
26 - error (EXIT_FAILURE, 0, "Could not drop privileges (setuid() failed)");
27 - }
28 + {
29 + error (EXIT_FAILURE, 0,
30 + "Could not drop privileges (setuid() failed)");
31 + }
32
33 source (argc, argv);
34 exit (errs);
35 @@ -358,9 +359,10 @@ main (int argc, char *argv[])
36 if (to_option)
37 { /* Receive data. */
38 if (setuid (userid) == -1)
39 - {
40 - error (EXIT_FAILURE, 0, "Could not drop privileges (setuid() failed)");
41 - }
42 + {
43 + error (EXIT_FAILURE, 0,
44 + "Could not drop privileges (setuid() failed)");
45 + }
46
47 sink (argc, argv);
48 exit (errs);
49 @@ -548,9 +550,10 @@ toremote (char *targ, int argc, char *argv[])
50 free (bp);
51
52 if (setuid (userid) == -1)
53 - {
54 - error (EXIT_FAILURE, 0, "Could not drop privileges (setuid() failed)");
55 - }
56 + {
57 + error (EXIT_FAILURE, 0,
58 + "Could not drop privileges (setuid() failed)");
59 + }
60 }
61 source (1, argv + i);
62 close (rem);
63 @@ -645,9 +648,10 @@ tolocal (int argc, char *argv[])
64 }
65
66 if (seteuid (userid) == -1)
67 - {
68 - error (EXIT_FAILURE, 0, "Could not drop privileges (seteuid() failed)");
69 - }
70 + {
71 + error (EXIT_FAILURE, 0,
72 + "Could not drop privileges (seteuid() failed)");
73 + }
74
75 #if defined IP_TOS && defined IPPROTO_IP && defined IPTOS_THROUGHPUT
76 sslen = sizeof (ss);
77 @@ -663,9 +667,10 @@ tolocal (int argc, char *argv[])
78 sink (1, vect);
79
80 if (seteuid (effuid) == -1)
81 - {
82 - error (EXIT_FAILURE, 0, "Could not drop privileges (seteuid() failed)");
83 - }
84 + {
85 + error (EXIT_FAILURE, 0,
86 + "Could not drop privileges (seteuid() failed)");
87 + }
88
89 close (rem);
90 rem = -1;
91 @@ -1465,9 +1470,10 @@ susystem (char *s, int userid)
92
93 case 0:
94 if (setuid (userid) == -1)
95 - {
96 - error (EXIT_FAILURE, 0, "Could not drop privileges (setuid() failed)");
97 - }
98 + {
99 + error (EXIT_FAILURE, 0,
100 + "Could not drop privileges (setuid() failed)");
101 + }
102
103 execl (PATH_BSHELL, "sh", "-c", s, NULL);
104 _exit (127);
105 diff --git a/src/rlogin.c b/src/rlogin.c
106 index c543de0c..4360202f 100644
107 --- a/src/rlogin.c
108 +++ b/src/rlogin.c
109 @@ -648,14 +648,14 @@ try_connect:
110 to get the privileged port that rcmd () uses. We now want, however,
111 to run as the real user who invoked us. */
112 if (seteuid (uid) == -1)
113 - {
114 - error (EXIT_FAILURE, 0, "Could not drop privileges (seteuid() failed)");
115 - }
116 + {
117 + error (EXIT_FAILURE, 0, "Could not drop privileges (seteuid() failed)");
118 + }
119
120 if (setuid (uid) == -1)
121 - {
122 - error (EXIT_FAILURE, 0, "Could not drop privileges (setuid() failed)");
123 - }
124 + {
125 + error (EXIT_FAILURE, 0, "Could not drop privileges (setuid() failed)");
126 + }
127
128 doit (&osmask); /* The old mask will activate SIGURG and SIGUSR1! */
129
130 diff --git a/src/rsh.c b/src/rsh.c
131 index 6f60667d..179b47cd 100644
132 --- a/src/rsh.c
133 +++ b/src/rsh.c
134 @@ -278,14 +278,14 @@ main (int argc, char **argv)
135 *argv = (char *) "rlogin";
136
137 if (seteuid (getuid ()) == -1)
138 - {
139 - error (EXIT_FAILURE, errno, "seteuid() failed");
140 - }
141 + {
142 + error (EXIT_FAILURE, errno, "seteuid() failed");
143 + }
144
145 if (setuid (getuid ()) == -1)
146 - {
147 - error (EXIT_FAILURE, errno, "setuid() failed");
148 - }
149 + {
150 + error (EXIT_FAILURE, errno, "setuid() failed");
151 + }
152
153 execv (PATH_RLOGIN, argv);
154 error (EXIT_FAILURE, errno, "cannot execute %s", PATH_RLOGIN);
155 @@ -551,14 +551,14 @@ try_connect:
156 }
157
158 if (seteuid (uid) == -1)
159 - {
160 - error (EXIT_FAILURE, errno, "seteuid() failed");
161 - }
162 + {
163 + error (EXIT_FAILURE, errno, "seteuid() failed");
164 + }
165
166 if (setuid (uid) == -1)
167 - {
168 - error (EXIT_FAILURE, errno, "setuid() failed");
169 - }
170 + {
171 + error (EXIT_FAILURE, errno, "setuid() failed");
172 + }
173
174 #ifdef HAVE_SIGACTION
175 sigemptyset (&sigs);
176 diff --git a/src/rshd.c b/src/rshd.c
177 index 707790e7..3a153a18 100644
178 --- a/src/rshd.c
179 +++ b/src/rshd.c
180 @@ -1848,16 +1848,16 @@ doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)
181
182 /* Set the gid, then uid to become the user specified by "locuser" */
183 if (setegid ((gid_t) pwd->pw_gid) == -1)
184 - {
185 - rshd_error ("Cannot drop privileges (setegid() failed)\n");
186 - exit (EXIT_FAILURE);
187 - }
188 + {
189 + rshd_error ("Cannot drop privileges (setegid() failed)\n");
190 + exit (EXIT_FAILURE);
191 + }
192
193 if (setgid ((gid_t) pwd->pw_gid) == -1)
194 - {
195 - rshd_error ("Cannot drop privileges (setgid() failed)\n");
196 - exit (EXIT_FAILURE);
197 - }
198 + {
199 + rshd_error ("Cannot drop privileges (setgid() failed)\n");
200 + exit (EXIT_FAILURE);
201 + }
202
203 #ifdef HAVE_INITGROUPS
204 initgroups (pwd->pw_name, pwd->pw_gid); /* BSD groups */
205 @@ -1881,10 +1881,10 @@ doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)
206 #endif /* WITH_PAM */
207
208 if (setuid ((uid_t) pwd->pw_uid) == -1)
209 - {
210 - rshd_error ("Cannot drop privileges (setuid() failed)\n");
211 - exit (EXIT_FAILURE);
212 - }
213 + {
214 + rshd_error ("Cannot drop privileges (setuid() failed)\n");
215 + exit (EXIT_FAILURE);
216 + }
217
218 /* We'll execute the client's command in the home directory
219 * of locuser. Note, that the chdir must be executed after
220 diff --git a/src/uucpd.c b/src/uucpd.c
221 index 29cfce35..fde7b9c9 100644
222 --- a/src/uucpd.c
223 +++ b/src/uucpd.c
224 @@ -254,10 +254,10 @@ doit (struct sockaddr *sap, socklen_t salen)
225 dologin (pw, sap, salen);
226
227 if (setgid (pw->pw_gid) == -1)
228 - {
229 - fprintf (stderr, "setgid() failed");
230 - return;
231 - }
232 + {
233 + fprintf (stderr, "setgid() failed");
234 + return;
235 + }
236 #ifdef HAVE_INITGROUPS
237 initgroups (pw->pw_name, pw->pw_gid);
238 #endif
239 @@ -268,10 +268,10 @@ doit (struct sockaddr *sap, socklen_t salen)
240 }
241
242 if (setuid (pw->pw_uid) == -1)
243 - {
244 - fprintf (stderr, "setuid() failed");
245 - return;
246 - }
247 + {
248 + fprintf (stderr, "setuid() failed");
249 + return;
250 + }
251
252 execl (uucico_location, "uucico", NULL);
253 perror ("uucico server: execl");