Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb83c110

Browse files
culyerrzimmerle
culyerr
authored andcommitted
Fixed IPv4+Port address parsing
1 parentb1ee051 commitb83c110

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎iis/mymodule.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ class REQUEST_STORED_CONTEXT : public IHttpStoredContext
8888

8989
char *GetIpAddr(apr_pool_t *pool, PSOCKADDR pAddr)
9090
{
91+
constchar *format ="%15[0-9.]:%5[0-9]";
92+
char ip[16] = {0 };// ip4 addresses have max len 15
93+
char port[6] = {0 };// port numbers are 16bit, ie 5 digits max
94+
9195
DWORD len =50;
9296
char *buf = (char *)apr_palloc(pool, len);
9397

@@ -98,6 +102,14 @@ char *GetIpAddr(apr_pool_t *pool, PSOCKADDR pAddr)
98102

99103
WSAAddressToString(pAddr,sizeof(SOCKADDR),NULL, buf, &len);
100104

105+
// test for IPV4 with port on the end
106+
if (sscanf(buf, format, ip, port) ==2) {
107+
// IPV4 but with port - remove the port
108+
char* input =":";
109+
char* ipv4 =strtok(buf, input);
110+
return ipv4;
111+
}
112+
101113
return buf;
102114
}
103115

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp