mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-02 03:48:02 +00:00
Fix incorrect ACL behavior when CIDR notation of "/0" is used.
AST-2010-003 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@248946 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -298,7 +298,14 @@ struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha
|
||||
|
||||
if (!strchr(nm, '.')) {
|
||||
if ((sscanf(nm, "%30d", &x) == 1) && (x >= 0) && (x <= 32)) {
|
||||
ha->netmask.s_addr = htonl(0xFFFFFFFF << (32 - x));
|
||||
if (x == 0) {
|
||||
/* This is special-cased to prevent unpredictable
|
||||
* behavior of shifting left 32 bits
|
||||
*/
|
||||
ha->netmask.s_addr = 0;
|
||||
} else {
|
||||
ha->netmask.s_addr = htonl(0xFFFFFFFF << (32 - x));
|
||||
}
|
||||
} else {
|
||||
ast_log(LOG_WARNING, "Invalid CIDR in %s\n", stuff);
|
||||
ast_free(ha);
|
||||
|
||||
Reference in New Issue
Block a user