ETHER: Silence Coverity indicated potential issues
This commit is contained in:
parent
7d079990df
commit
de335bfd6a
1 changed files with 14 additions and 15 deletions
27
sim_ether.c
27
sim_ether.c
|
@ -1653,7 +1653,9 @@ static int _eth_get_system_id (char *buf, size_t buf_size)
|
|||
#endif
|
||||
if ((status = RegOpenKeyExA (HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Cryptography", 0, KEY_QUERY_VALUE|KEY_WOW64_64KEY, ®hnd)) != ERROR_SUCCESS)
|
||||
return -1;
|
||||
reglen = buf_size;
|
||||
if (buf_size < 37)
|
||||
return -1;
|
||||
reglen = buf_size - 1;
|
||||
if ((status = RegQueryValueExA (reghnd, "MachineGuid", NULL, ®type, (LPBYTE)buf, ®len)) != ERROR_SUCCESS) {
|
||||
RegCloseKey (reghnd);
|
||||
return -1;
|
||||
|
@ -1672,19 +1674,16 @@ static int _eth_get_system_id (char *buf, size_t buf_size)
|
|||
FILE *f;
|
||||
|
||||
memset (buf, 0, buf_size);
|
||||
if ((f = fopen ("/etc/machine-id", "r"))) {
|
||||
if (fread (buf, 1, buf_size - 1, f))
|
||||
if (buf_size < 37)
|
||||
return -1;
|
||||
if ((f = fopen ("/etc/machine-id", "r")) == NULL)
|
||||
f = popen ("hostname", "r");
|
||||
if (f) {
|
||||
size_t read_size;
|
||||
|
||||
read_size = fread (buf, 1, buf_size - 1, f);
|
||||
buf[read_size] = '\0';
|
||||
fclose (f);
|
||||
else
|
||||
fclose (f);
|
||||
}
|
||||
else {
|
||||
if ((f = popen ("hostname", "r"))) {
|
||||
if (fread (buf, 1, buf_size - 1, f))
|
||||
pclose (f);
|
||||
else
|
||||
pclose (f);
|
||||
}
|
||||
}
|
||||
while ((strlen (buf) > 0) && sim_isspace(buf[strlen (buf) - 1]))
|
||||
buf[strlen (buf) - 1] = '\0';
|
||||
|
@ -2073,7 +2072,7 @@ if (0 == strncmp("tap:", savname, 4)) {
|
|||
strcpy(savname, devname);
|
||||
}
|
||||
#if defined (__APPLE__)
|
||||
if (1) {
|
||||
if (tun < 0) { /* Not good yet? */
|
||||
struct ifreq ifr;
|
||||
int s;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue