View | Details | Raw Unified | Return to bug 3171
Collapse All | Expand All

(-)usr.bin/ssh/misc.c (-1 / +2 lines)
Lines 452-458 a2tun(const char *s, int *remote) Link Here
452
long
452
long
453
convtime(const char *s)
453
convtime(const char *s)
454
{
454
{
455
	long total, secs, multiplier = 1;
455
	long total, secs, multiplier;
456
	const char *p;
456
	const char *p;
457
	char *endp;
457
	char *endp;
458
458
Lines 470-475 convtime(const char *s) Link Here
470
		    secs < 0)
470
		    secs < 0)
471
			return -1;
471
			return -1;
472
472
473
		multiplier = 1;
473
		switch (*endp++) {
474
		switch (*endp++) {
474
		case '\0':
475
		case '\0':
475
			endp--;
476
			endp--;
(-)regress/usr.bin/ssh/unittests/misc/tests.c (+19 lines)
Lines 76-79 tests(void) Link Here
76
	ASSERT_STRING_EQ(path, "some/path");
76
	ASSERT_STRING_EQ(path, "some/path");
77
	free(user); free(host); free(path);
77
	free(user); free(host); free(path);
78
	TEST_DONE();
78
	TEST_DONE();
79
80
	TEST_START("misc_convtime");
81
	ASSERT_LONG_EQ(convtime("1"), 1);
82
	ASSERT_LONG_EQ(convtime("2s"), 2);
83
	ASSERT_LONG_EQ(convtime("3m"), 180);
84
	ASSERT_LONG_EQ(convtime("1m30"), 90);
85
	ASSERT_LONG_EQ(convtime("1m30s"), 90);
86
	ASSERT_LONG_EQ(convtime("1h1s"), 3601);
87
	ASSERT_LONG_EQ(convtime("1h30m"), 90 * 60);
88
	ASSERT_LONG_EQ(convtime("1d"), 24 * 60 * 60);
89
	ASSERT_LONG_EQ(convtime("1w"), 7 * 24 * 60 * 60);
90
	ASSERT_LONG_EQ(convtime("1w2d3h4m5"), 788645);
91
	ASSERT_LONG_EQ(convtime("1w2d3h4m5s"), 788645);
92
	/* any negative number or error returns -1 */
93
	ASSERT_LONG_EQ(convtime("-1"),  -1);
94
	ASSERT_LONG_EQ(convtime(""),  -1);
95
	ASSERT_LONG_EQ(convtime("trout"),  -1);
96
	ASSERT_LONG_EQ(convtime("-77"),  -1);
97
	TEST_DONE();
79
}
98
}

Return to bug 3171