View | Details | Raw Unified | Return to bug 2329 | Differences between
and this patch

Collapse All | Expand All

(-)src/usr.bin/ssh/auth-options.c (-29 / +47 lines)
Lines 203-242 Link Here
203
			goto next_option;
203
			goto next_option;
204
		}
204
		}
205
		cp = "environment=\"";
205
		cp = "environment=\"";
206
		if (options.permit_user_env &&
206
		if (strncasecmp(opts, cp, strlen(cp)) == 0) {
207
		    strncasecmp(opts, cp, strlen(cp)) == 0) {
207
			if (options.permit_user_env) {
208
			char *s;
208
				char *s;
209
			struct envstring *new_envstring;
209
				struct envstring *new_envstring;
210
210
211
			opts += strlen(cp);
211
				opts += strlen(cp);
212
			s = xmalloc(strlen(opts) + 1);
212
				s = xmalloc(strlen(opts) + 1);
213
			i = 0;
213
				i = 0;
214
			while (*opts) {
214
				while (*opts) {
215
				if (*opts == '"')
215
					if (*opts == '"')
216
					break;
216
						break;
217
				if (*opts == '\\' && opts[1] == '"') {
217
					if (*opts == '\\' && opts[1] == '"') {
218
					opts += 2;
218
						opts += 2;
219
					s[i++] = '"';
219
						s[i++] = '"';
220
					continue;
220
						continue;
221
					}
222
					s[i++] = *opts++;
221
				}
223
				}
222
				s[i++] = *opts++;
224
				if (!*opts) {
225
					debug("%.100s, line %lu: missing end quote",
226
						file, linenum);
227
					auth_debug_add("%.100s, line %lu: missing end quote",
228
						file, linenum);
229
					free(s);
230
					goto bad_option;
231
				}
232
				s[i] = '\0';
233
				auth_debug_add("Adding to environment: %.900s", s);
234
				debug("Adding to environment: %.900s", s);
235
				new_envstring = xcalloc(1, sizeof(struct envstring));
236
				new_envstring->s = s;
237
				new_envstring->next = custom_environment;
238
				custom_environment = new_envstring;
223
			}
239
			}
224
			if (!*opts) {
240
			else {
225
				debug("%.100s, line %lu: missing end quote",
241
				while (*opts) {
226
				    file, linenum);
242
					if (*opts == '"')
227
				auth_debug_add("%.100s, line %lu: missing end quote",
243
						break;
228
				    file, linenum);
244
					if (*opts == '\\' && opts[1] == '"') {
229
				free(s);
245
						opts += 2;
230
				goto bad_option;
246
						continue;
247
					}
248
				}
249
				if (!*opts) {
250
					debug("%.100s, line %lu: missing end quote",
251
						file, linenum);
252
					auth_debug_add("%.100s, line %lu: missing end quote",
253
						file, linenum);
254
					goto bad_option;
255
				}
231
			}
256
			}
232
			s[i] = '\0';
233
			auth_debug_add("Adding to environment: %.900s", s);
234
			debug("Adding to environment: %.900s", s);
235
			opts++;
257
			opts++;
236
			new_envstring = xcalloc(1, sizeof(struct envstring));
237
			new_envstring->s = s;
238
			new_envstring->next = custom_environment;
239
			custom_environment = new_envstring;
240
			goto next_option;
258
			goto next_option;
241
		}
259
		}
242
		cp = "from=\"";
260
		cp = "from=\"";

Return to bug 2329