File tree Expand file tree Collapse file tree 2 files changed +3
-3
lines changed
Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -143,9 +143,7 @@ char* hostname_cleanup(char *s) {
143143
144144 assert (s );
145145
146- strshorten (s , HOST_NAME_MAX );
147-
148- for (p = s , d = s , dot = hyphen = true; * p ; p ++ )
146+ for (p = s , d = s , dot = hyphen = true; * p && d - s < HOST_NAME_MAX ; p ++ )
149147 if (* p == '.' ) {
150148 if (dot || hyphen )
151149 continue ;
Original file line number Diff line number Diff line change @@ -85,6 +85,8 @@ static void test_hostname_cleanup(void) {
8585 assert_se (streq (hostname_cleanup (s ), "foo.bar" ));
8686 s = strdupa ("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" );
8787 assert_se (streq (hostname_cleanup (s ), "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ));
88+ s = strdupa ("xxxx........xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" );
89+ assert_se (streq (hostname_cleanup (s ), "xxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ));
8890}
8991
9092static void test_read_etc_hostname (void ) {
You can’t perform that action at this time.
0 commit comments