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

Collapse All | Expand All

(-)a/regress/Makefile (+1 lines)
Lines 79-84 LTESTS= connect \ Link Here
79
		principals-command \
79
		principals-command \
80
		cert-file \
80
		cert-file \
81
		cfginclude \
81
		cfginclude \
82
		cfg-longline \
82
		allow-deny-users
83
		allow-deny-users
83
84
84
85
(-)a/regress/cfg-longline.sh (-1 / +83 lines)
Line 0 Link Here
0
- 
1
#
2
# regression test for the long config line problem.
3
# the bug we are testing for is this:
4
#
5
# in the buggy versions of ssh, if the config file contained
6
# a line longer than 1022 chars, any content beyond that was
7
# treated as a separate line or lines.  if the long line happened
8
# to be a comment line, the remainder of the line would be treated
9
# as normal input, resulting in nonsensical error messages.
10
#
11
# also, if the config file contained any other errors later on,
12
# the reported line numbers would be incorrect.
13
# 
14
15
# remove temp files created for this test
16
cleanup()
17
{
18
	/bin/rm -f "$FAKE_CONFIG_FILE"
19
}
20
21
# print a string s, filled out with blanks to the given length.
22
lenline()
23
{
24
	len="$1" s="$2"
25
	printf "%-${len}.${len}s\n" "$s"
26
}
27
28
#
29
# create a config file with some long lines to trigger
30
# the long line bug if it is present.
31
#
32
mkconfig()
33
{
34
	n="$READCONF_MAX_LINE_LENGTH"
35
	lenline "$n"          "# 1. just at the limit, should be ok"
36
	lenline `expr $n + 1` "# 2. over the limit should be an Error"
37
	echo                  "# 3. ok"
38
	echo                  "# 4. ok"
39
	echo                  "# 5. ok"
40
	echo                  "6. this line should cause an Error"
41
}
42
43
# given the output, print on one line the line numbers of lines with errors.
44
get_line_numbers()
45
{
46
	elines=`echo "$*" | sed -n -e 's/.*line \([0-9]*\):.*/\1/p' | sort -u`
47
	echo $elines
48
}
49
50
main()
51
{
52
	verbose "test $tid: $DESC"
53
54
	mkconfig > "$FAKE_CONFIG_FILE" || exit 1
55
	err=`ssh -F "$FAKE_CONFIG_FILE" -NnTx 127.0.0.1 date 2>&1`
56
	xstat=$?
57
58
	cleanup
59
60
	# the command should have failed.
61
	if [ "$xstat" -eq 0 ]; then
62
		fail "expected failure did not happen"
63
	fi
64
65
	# get the line numbers of the errors"
66
	errlines=`get_line_numbers "$err"`
67
68
	# lines 2 and 6 only should have errors
69
	expected="2 6"
70
71
	if [ x"$errlines" != x"$expected" ]; then
72
		fail "errlines=$errlines; expected $expected"
73
	fi
74
}
75
76
# ----- start of mainline code
77
DESC="test long config lines"
78
tid="cfg-longline"
79
80
READCONF_MAX_LINE_LENGTH=1022
81
FAKE_CONFIG_FILE=/tmp/fake-ssh-config-$$.tmp
82
83
main

Return to bug 2651