local_host_ip_addrs_to_string: fix buffer overflow
parent
564facf33e
commit
15424dfc1c
3
HISTORY
3
HISTORY
|
|
@ -1,4 +1,7 @@
|
|||
|
||||
Version 1.88 2026-09-03
|
||||
* local_host_ip_addrs_to_string: fix buffer overflow
|
||||
|
||||
Version 1.87 2026-07-10
|
||||
* ini_file_readers can refer env variable such as %{env::FASTDFS_IPADDR}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ libfastcommon是在github开源的⼀个C函数库。它提供了ini⽂件解析
|
|||
## ini_file_reader的主要特点:
|
||||
|
||||
### 1、⽀持section
|
||||
例如:
|
||||
例如:
|
||||
```
|
||||
[workers]
|
||||
threads = 4
|
||||
|
|
|
|||
|
|
@ -70,12 +70,21 @@ const char *local_host_ip_addrs_to_string(char *buff, const int size)
|
|||
|
||||
len = snprintf(buff, size, "local_host_ip_count: %d,",
|
||||
g_local_host_ip_count);
|
||||
if (len >= size)
|
||||
{
|
||||
return buff;
|
||||
}
|
||||
|
||||
pEnd = g_local_host_ip_addrs +
|
||||
IP_ADDRESS_SIZE * g_local_host_ip_count;
|
||||
for (p=g_local_host_ip_addrs; p<pEnd; p+=IP_ADDRESS_SIZE)
|
||||
{
|
||||
len += snprintf(buff + len, size - len, " %s", p);
|
||||
}
|
||||
{
|
||||
len += snprintf(buff + len, size - len, " %s", p);
|
||||
if (len >= size)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return buff;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue