Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
01197905
Commit
01197905
authored
9 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
When stripping port number, handle IPv6 addresses, and remove [] thing too.
parent
4c2caf47
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sbbs3/js_server.c
+23
-8
23 additions, 8 deletions
src/sbbs3/js_server.c
src/sbbs3/websrvr.c
+26
-9
26 additions, 9 deletions
src/sbbs3/websrvr.c
with
49 additions
and
17 deletions
src/sbbs3/js_server.c
+
23
−
8
View file @
01197905
...
...
@@ -150,15 +150,30 @@ static void remove_port_part(char *host)
{
char
*
p
=
strchr
(
host
,
0
)
-
1
;
if
(
!
isdigit
(
*
p
))
if
(
isdigit
(
*
p
))
{
/*
* If the first and last : are not the same, and it doesn't
* start with '[', there's no port part.
*/
if
(
host
[
0
]
!=
'['
)
{
if
(
strchr
(
host
,
':'
)
!=
strrchr
(
host
,
':'
))
return
;
}
for
(;
p
>=
host
;
p
--
)
{
if
(
*
p
==
':'
)
{
*
p
=
0
;
return
;
break
;
}
if
(
!
isdigit
(
*
p
))
return
;
break
;
}
}
// Now, remove []s...
if
(
host
[
0
]
==
'['
)
{
memmove
(
host
,
host
+
1
,
strlen
(
host
));
p
=
strchr
(
host
,
']'
);
if
(
p
)
*
p
=
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/sbbs3/websrvr.c
+
26
−
9
View file @
01197905
...
...
@@ -2820,19 +2820,36 @@ static int is_dynamic_req(http_session_t* session)
static
char
*
split_port_part
(
char
*
host
)
{
char
*
ret
=
NULL
;
char
*
p
=
strchr
(
host
,
0
)
-
1
;
if
(
!
isdigit
(
*
p
))
if
(
isdigit
(
*
p
))
{
/*
* If the first and last : are not the same, and it doesn't
* start with '[', there's no port part.
*/
if
(
host
[
0
]
!=
'['
)
{
if
(
strchr
(
host
,
':'
)
!=
strrchr
(
host
,
':'
))
return
NULL
;
}
for
(;
p
>=
host
;
p
--
)
{
if
(
*
p
==
':'
)
{
*
p
=
0
;
return
p
+
1
;
ret
=
p
+
1
;
break
;
}
if
(
!
isdigit
(
*
p
))
return
NULL
;
break
;
}
return
NULL
;
}
// Now, remove []s...
if
(
host
[
0
]
==
'['
)
{
memmove
(
host
,
host
+
1
,
strlen
(
host
));
p
=
strchr
(
host
,
']'
);
if
(
p
)
*
p
=
0
;
}
return
ret
;
}
static
void
remove_port_part
(
char
*
host
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment