Commit 4c4a820c authored by dukl's avatar dukl

fix bug: sx network(0.0.0.0)

parent 23abe818
...@@ -160,7 +160,8 @@ int get_inet_addr_from_iface(const std::string& if_name, struct in_addr& inet_ad ...@@ -160,7 +160,8 @@ int get_inet_addr_from_iface(const std::string& if_name, struct in_addr& inet_ad
memset(&ifr, 0, sizeof(ifr)); memset(&ifr, 0, sizeof(ifr));
int fd = socket(AF_INET, SOCK_DGRAM, 0); int fd = socket(AF_INET, SOCK_DGRAM, 0);
ifr.ifr_addr.sa_family = AF_INET; ifr.ifr_addr.sa_family = AF_INET;
strncpy(ifr.ifr_name, (const char *)if_name.c_str(), IFNAMSIZ-1); //strncpy(ifr.ifr_name, (const char *)if_name.c_str(), IFNAMSIZ-1);
strcpy(ifr.ifr_name,(const char*)if_name.c_str());
if (ioctl(fd, SIOCGIFADDR, &ifr)) { if (ioctl(fd, SIOCGIFADDR, &ifr)) {
close(fd); close(fd);
Logger::system().error("Failed to probe %s inet addr: error %s\n", if_name.c_str(), strerror(errno)); Logger::system().error("Failed to probe %s inet addr: error %s\n", if_name.c_str(), strerror(errno));
...@@ -205,7 +206,8 @@ int get_inet_addr_infos_from_iface(const std::string& if_name, struct in_addr& i ...@@ -205,7 +206,8 @@ int get_inet_addr_infos_from_iface(const std::string& if_name, struct in_addr& i
memset(&ifr, 0, sizeof(ifr)); memset(&ifr, 0, sizeof(ifr));
int fd = socket(AF_INET, SOCK_DGRAM, 0); int fd = socket(AF_INET, SOCK_DGRAM, 0);
ifr.ifr_addr.sa_family = AF_INET; ifr.ifr_addr.sa_family = AF_INET;
strncpy(ifr.ifr_name, (const char *)if_name.c_str(), IFNAMSIZ-1); //strncpy(ifr.ifr_name, (const char *)if_name.c_str(), IFNAMSIZ-1);
strcpy(ifr.ifr_name,(const char*)if_name.c_str());
if (ioctl(fd, SIOCGIFADDR, &ifr)) { if (ioctl(fd, SIOCGIFADDR, &ifr)) {
close(fd); close(fd);
Logger::system().error("Failed to probe %s inet addr: error %s\n", if_name.c_str(), strerror(errno)); Logger::system().error("Failed to probe %s inet addr: error %s\n", if_name.c_str(), strerror(errno));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment