mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-20 04:01:26 +00:00
Fix strtoul() overflow handling
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4318 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -617,11 +618,11 @@ static int netmask_match_v4(struct sockaddr *sa1, struct sockaddr *sa2, uint32_t
|
||||
|
||||
static int netmask_match(struct sockaddr *sa1, struct sockaddr *sa2, char *buf)
|
||||
{
|
||||
int32_t mbit;
|
||||
unsigned long mbit;
|
||||
uint8_t family = sa1->sa_family;
|
||||
|
||||
mbit = strtoul(buf, NULL, 0);
|
||||
if (mbit < 0 ||
|
||||
if (mbit == ULONG_MAX ||
|
||||
(family == AF_INET && mbit > 31) ||
|
||||
(family == AF_INET6 && mbit > 127))
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user