mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-20 19:41:58 +00:00
Fix 1452 - byte order issue in mg_check_ip_acl
This commit is contained in:
1 parent
1a8e3c2e31
commit
59c4dfa33b
3 files changed
+3
-3
No files matched your search
+1
-1
@@ -4630,7 +4630,7 @@ int mg_check_ip_acl(struct mg_str acl, uint32_t remote_ip) {
|
|||||||
uint32_t net, mask;
|
uint32_t net, mask;
|
||||||
if (k.ptr[0] != '+' && k.ptr[0] != '-') return -1;
|
if (k.ptr[0] != '+' && k.ptr[0] != '-') return -1;
|
||||||
if (parse_net(&k.ptr[1], &net, &mask) == 0) return -2;
|
if (parse_net(&k.ptr[1], &net, &mask) == 0) return -2;
|
||||||
if ((remote_ip & mask) == net) allowed = k.ptr[0];
|
if ((mg_ntohl(remote_ip) & mask) == net) allowed = k.ptr[0];
|
||||||
}
|
}
|
||||||
return allowed == '+';
|
return allowed == '+';
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -238,7 +238,7 @@ int mg_check_ip_acl(struct mg_str acl, uint32_t remote_ip) {
|
|||||||
uint32_t net, mask;
|
uint32_t net, mask;
|
||||||
if (k.ptr[0] != '+' && k.ptr[0] != '-') return -1;
|
if (k.ptr[0] != '+' && k.ptr[0] != '-') return -1;
|
||||||
if (parse_net(&k.ptr[1], &net, &mask) == 0) return -2;
|
if (parse_net(&k.ptr[1], &net, &mask) == 0) return -2;
|
||||||
if ((remote_ip & mask) == net) allowed = k.ptr[0];
|
if ((mg_ntohl(remote_ip) & mask) == net) allowed = k.ptr[0];
|
||||||
}
|
}
|
||||||
return allowed == '+';
|
return allowed == '+';
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1539,7 +1539,7 @@ static void test_udp(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void test_check_ip_acl(void) {
|
static void test_check_ip_acl(void) {
|
||||||
uint32_t ip = 0x01020304;
|
uint32_t ip = mg_htonl(0x01020304);
|
||||||
ASSERT(mg_check_ip_acl(mg_str(NULL), ip) == 1);
|
ASSERT(mg_check_ip_acl(mg_str(NULL), ip) == 1);
|
||||||
ASSERT(mg_check_ip_acl(mg_str(""), ip) == 1);
|
ASSERT(mg_check_ip_acl(mg_str(""), ip) == 1);
|
||||||
ASSERT(mg_check_ip_acl(mg_str("invalid"), ip) == -1);
|
ASSERT(mg_check_ip_acl(mg_str("invalid"), ip) == -1);
|
||||||
|
|||||||
Reference in new issue
Block a user