mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-11-23 01:49:53 +03:00
Clean up device name parsing code to eliminate Coverity errors
This commit is contained in:
parent
64b68c15f4
commit
2017e43ad1
@ -1126,7 +1126,7 @@ bool DlipReceiveAck(int fd)
|
|||||||
|
|
||||||
#endif // UNIX_SOLARIS
|
#endif // UNIX_SOLARIS
|
||||||
|
|
||||||
// Separate UNIX device name string into device name and id number
|
// Validate device name and return proper device path according to system type
|
||||||
bool ParseUnixEthDeviceName(char *dst_devname, UINT dst_devname_size, char *src_name)
|
bool ParseUnixEthDeviceName(char *dst_devname, UINT dst_devname_size, char *src_name)
|
||||||
{
|
{
|
||||||
UINT len, i;
|
UINT len, i;
|
||||||
@ -1141,9 +1141,8 @@ bool ParseUnixEthDeviceName(char *dst_devname, UINT dst_devname_size, char *src_
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strlen(src_name);
|
|
||||||
// Check string length
|
// Check string length
|
||||||
if(len == 0)
|
if (IsEmptyStr(src_name))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1159,27 +1158,22 @@ bool ParseUnixEthDeviceName(char *dst_devname, UINT dst_devname_size, char *src_
|
|||||||
device_path = "/dev/";
|
device_path = "/dev/";
|
||||||
}
|
}
|
||||||
|
|
||||||
device_pathlen = strlen(device_path);
|
device_pathlen = StrLen(device_path);
|
||||||
|
|
||||||
for (i = len-1; i+1 != 0; i--)
|
// Last character must be a number
|
||||||
{
|
|
||||||
// Find last non-numeric character
|
|
||||||
if (src_name[i] < '0' || '9' < src_name[i])
|
if (src_name[i] < '0' || '9' < src_name[i])
|
||||||
{
|
{
|
||||||
// last character must be a number
|
if (src_name[i + 1] == 0)
|
||||||
if(src_name[i+1]==0)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StrCpy(dst_devname, dst_devname_size, device_path);
|
StrCpy(dst_devname, dst_devname_size, device_path);
|
||||||
StrCpy(dst_devname + device_pathlen, dst_devname_size-device_pathlen, src_name);
|
StrCpy(dst_devname + device_pathlen, dst_devname_size - device_pathlen, src_name);
|
||||||
dst_devname[device_pathlen + len] = 0;
|
dst_devname[device_pathlen + len] = 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
// All characters in the string was numeric: error
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BRIDGE_BPF) || defined(BRIDGE_PCAP)
|
#if defined(BRIDGE_BPF) || defined(BRIDGE_PCAP)
|
||||||
|
Loading…
Reference in New Issue
Block a user