summaryrefslogtreecommitdiff
path: root/poky/meta/recipes-connectivity/inetutils/inetutils/0002-CVE-2023-40303-Indent-changes-in-previous-commit.patch
blob: f4252b5f34f4ab30754946504dd58fdd953dbedc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
From 9122999252c7e21eb7774de11d539748e7bdf46d Mon Sep 17 00:00:00 2001
From: Simon Josefsson <simon@josefsson.org>
Date: Tue, 29 Aug 2023 06:42:11 +0000
Subject: [PATCH] CVE-2023-40303: Indent changes in previous commit.

CVE: CVE-2023-40303

Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=9122999252c7e21eb7774de11d539748e7bdf46d]

Signed-off-by: Yogita Urade <yogita.urade@windriver.com>
---
 src/rcp.c    | 42 ++++++++++++++++++++++++------------------
 src/rlogin.c | 12 ++++++------
 src/rsh.c    | 26 +++++++++++++-------------
 src/rshd.c   | 24 ++++++++++++------------
 src/uucpd.c  | 16 ++++++++--------
 5 files changed, 63 insertions(+), 57 deletions(-)

diff --git a/src/rcp.c b/src/rcp.c
index 7018e35..e504f8a 100644
--- a/src/rcp.c
+++ b/src/rcp.c
@@ -347,9 +347,10 @@ main (int argc, char *argv[])
       response ();

       if (setuid (userid) == -1)
-      {
-	error (EXIT_FAILURE, 0, "Could not drop privileges (setuid() failed)");
-      }
+	{
+	  error (EXIT_FAILURE, 0,
+		 "Could not drop privileges (setuid() failed)");
+	}

       source (argc, argv);
       exit (errs);
@@ -358,9 +359,10 @@ main (int argc, char *argv[])
   if (to_option)
     {				/* Receive data. */
       if (setuid (userid) == -1)
-      {
-	error (EXIT_FAILURE, 0, "Could not drop privileges (setuid() failed)");
-      }
+	{
+	  error (EXIT_FAILURE, 0,
+		 "Could not drop privileges (setuid() failed)");
+	}

       sink (argc, argv);
       exit (errs);
@@ -548,9 +550,10 @@ toremote (char *targ, int argc, char *argv[])
	      free (bp);

	      if (setuid (userid) == -1)
-	      {
-		error (EXIT_FAILURE, 0, "Could not drop privileges (setuid() failed)");
-	      }
+		{
+		  error (EXIT_FAILURE, 0,
+			 "Could not drop privileges (setuid() failed)");
+		}
	    }
	  source (1, argv + i);
	  close (rem);
@@ -645,9 +648,10 @@ tolocal (int argc, char *argv[])
	}

       if (seteuid (userid) == -1)
-      {
-	error (EXIT_FAILURE, 0, "Could not drop privileges (seteuid() failed)");
-      }
+	{
+	  error (EXIT_FAILURE, 0,
+		 "Could not drop privileges (seteuid() failed)");
+	}

 #if defined IP_TOS && defined IPPROTO_IP && defined IPTOS_THROUGHPUT
       sslen = sizeof (ss);
@@ -663,9 +667,10 @@ tolocal (int argc, char *argv[])
       sink (1, vect);

       if (seteuid (effuid) == -1)
-      {
-	      error (EXIT_FAILURE, 0, "Could not drop privileges (seteuid() failed)");
-      }
+	{
+	  error (EXIT_FAILURE, 0,
+		 "Could not drop privileges (seteuid() failed)");
+	}

       close (rem);
       rem = -1;
@@ -1465,9 +1470,10 @@ susystem (char *s, int userid)

     case 0:
       if (setuid (userid) == -1)
-      {
-	error (EXIT_FAILURE, 0, "Could not drop privileges (setuid() failed)");
-      }
+	{
+	  error (EXIT_FAILURE, 0,
+		 "Could not drop privileges (setuid() failed)");
+	}

       execl (PATH_BSHELL, "sh", "-c", s, NULL);
       _exit (127);
diff --git a/src/rlogin.c b/src/rlogin.c
index 9bf9645..a0c1237 100644
--- a/src/rlogin.c
+++ b/src/rlogin.c
@@ -648,14 +648,14 @@ try_connect:
      to get the privileged port that rcmd () uses.  We now want, however,
      to run as the real user who invoked us.  */
   if (seteuid (uid) == -1)
-  {
-   error (EXIT_FAILURE, 0, "Could not drop privileges (seteuid() failed)");
-  }
+    {
+      error (EXIT_FAILURE, 0, "Could not drop privileges (seteuid() failed)");
+    }

   if (setuid (uid) == -1)
-  {
-   error (EXIT_FAILURE, 0, "Could not drop privileges (setuid() failed)");
-  }
+    {
+      error (EXIT_FAILURE, 0, "Could not drop privileges (setuid() failed)");
+    }

   doit (&osmask);	/* The old mask will activate SIGURG and SIGUSR1!  */

diff --git a/src/rsh.c b/src/rsh.c
index 7b9cf22..c8f50d3 100644
--- a/src/rsh.c
+++ b/src/rsh.c
@@ -278,14 +278,14 @@ main (int argc, char **argv)
	*argv = (char *) "rlogin";

       if (seteuid (getuid ()) == -1)
-      {
-        error (EXIT_FAILURE, errno, "seteuid() failed");
-      }
-
+	{
+	  error (EXIT_FAILURE, errno, "seteuid() failed");
+	}
+
       if (setuid (getuid ()) == -1)
-      {
-	error (EXIT_FAILURE, errno, "setuid() failed");
-      }
+	{
+	  error (EXIT_FAILURE, errno, "setuid() failed");
+	}

       execv (PATH_RLOGIN, argv);
       error (EXIT_FAILURE, errno, "cannot execute %s", PATH_RLOGIN);
@@ -551,14 +551,14 @@ try_connect:
     }

   if (seteuid (uid) == -1)
-  {
-    error (EXIT_FAILURE, errno, "seteuid() failed");
-  }
+    {
+      error (EXIT_FAILURE, errno, "seteuid() failed");
+    }

   if (setuid (uid) == -1)
-  {
-    error (EXIT_FAILURE, errno, "setuid() failed");
-  }
+    {
+      error (EXIT_FAILURE, errno, "setuid() failed");
+    }

 #ifdef HAVE_SIGACTION
   sigemptyset (&sigs);
diff --git a/src/rshd.c b/src/rshd.c
index 707790e..df43edf 100644
--- a/src/rshd.c
+++ b/src/rshd.c
@@ -1848,16 +1848,16 @@ doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)

   /* Set the gid, then uid to become the user specified by "locuser" */
   if (setegid ((gid_t) pwd->pw_gid) == -1)
-  {
-    rshd_error ("Cannot drop privileges (setegid() failed)\n");
-    exit (EXIT_FAILURE);
-  }
+    {
+      rshd_error ("Cannot drop privileges (setegid() failed)\n");
+      exit (EXIT_FAILURE);
+    }

   if (setgid ((gid_t) pwd->pw_gid) == -1)
-  {
-    rshd_error ("Cannot drop privileges (setgid() failed)\n");
-    exit (EXIT_FAILURE);
-  }
+    {
+      rshd_error ("Cannot drop privileges (setgid() failed)\n");
+      exit (EXIT_FAILURE);
+    }

 #ifdef HAVE_INITGROUPS
   initgroups (pwd->pw_name, pwd->pw_gid);	/* BSD groups */
@@ -1881,10 +1881,10 @@ doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)
 #endif /* WITH_PAM */

   if (setuid ((uid_t) pwd->pw_uid) == -1)
-  {
-    rshd_error ("Cannot drop privileges (setuid() failed)\n");
-    exit (EXIT_FAILURE);
-  }
+    {
+      rshd_error ("Cannot drop privileges (setuid() failed)\n");
+      exit (EXIT_FAILURE);
+    }

   /* We'll execute the client's command in the home directory
    * of locuser. Note, that the chdir must be executed after
diff --git a/src/uucpd.c b/src/uucpd.c
index 29cfce3..afe24f3 100644
--- a/src/uucpd.c
+++ b/src/uucpd.c
@@ -254,10 +254,10 @@ doit (struct sockaddr *sap, socklen_t salen)
   dologin (pw, sap, salen);

   if (setgid (pw->pw_gid) == -1)
-  {
-    fprintf (stderr, "setgid() failed");
-    return;
-  }
+    {
+      fprintf (stderr, "setgid() failed");
+      return;
+    }
 #ifdef HAVE_INITGROUPS
   initgroups (pw->pw_name, pw->pw_gid);
 #endif
@@ -268,10 +268,10 @@ doit (struct sockaddr *sap, socklen_t salen)
     }

   if (setuid (pw->pw_uid) == -1)
-  {
-    fprintf (stderr, "setuid() failed");
-    return;
-  }
+    {
+      fprintf (stderr, "setuid() failed");
+      return;
+    }

   execl (uucico_location, "uucico", NULL);
   perror ("uucico server: execl");
--
2.40.0