Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SRS 3.0 does not check if the address is empty when reading IP. #1087

Closed
typcn opened this issue Mar 9, 2018 · 4 comments
Closed

SRS 3.0 does not check if the address is empty when reading IP. #1087

typcn opened this issue Mar 9, 2018 · 4 comments
Assignees
Labels
Bug It might be a bug. TransByAI Translated by AI/GPT.
Milestone

Comments

@typcn
Copy link

typcn commented Mar 9, 2018

image

In srs_service_utility.cpp line 135, ifa_addr may be empty, causing a crash at startup.

TRANS_BY_GPT3

@winlinvip winlinvip added the Bug It might be a bug. label Jul 30, 2018
@winlinvip winlinvip added this to the srs 3.0 release milestone Jul 30, 2018
@winlinvip
Copy link
Member

winlinvip commented Jul 30, 2018

Can't the network card be read?

TRANS_BY_GPT3

@typcn
Copy link
Author

typcn commented Jul 30, 2018

--- a/trunk/src/service/srs_service_utility.cpp
+++ b/trunk/src/service/srs_service_utility.cpp
@@ -149,7 +149,7 @@ void retrieve_local_ips()
     // Discover IPv4 first.
     for (ifaddrs* p = ifap; p ; p = p->ifa_next) {
         ifaddrs* cur = p;
-        
+        if(!cur->ifa_addr) continue;
         // retrieve IP address, ignore the tun0 network device, whose addr is NULL.
         // @see: https://github.com/ossrs/srs/issues/141
         bool ipv4 = (cur->ifa_addr->sa_family == AF_INET);
@@ -163,7 +163,7 @@ void retrieve_local_ips()
     // Then, discover IPv6 addresses.
     for (ifaddrs* p = ifap; p ; p = p->ifa_next) {
         ifaddrs* cur = p;
-        
+        if(!cur->ifa_addr) continue;
         // retrieve IP address, ignore the tun0 network device, whose addr is NULL.
         // @see: https://github.com/ossrs/srs/issues/141
         bool ipv6 = (cur->ifa_addr->sa_family == AF_INET6);

If a network card does not have any IP address, ifa_addr will be empty, so it needs to be checked.

TRANS_BY_GPT3

@winlinvip
Copy link
Member

👍

@winlinvip winlinvip self-assigned this Sep 12, 2021
@wangzhengqiang
Copy link

wangzhengqiang commented Nov 29, 2021

srs did not obtain an IPv4 address, but obtained an IPv6 address, causing an error in the RTMP connection socket. It is necessary to specify the network card address, as automatic DHCP address acquisition is not working. Therefore, configure the specified IP or server_id configuration.

TRANS_BY_GPT3

@winlinvip winlinvip changed the title SRS 3.0 在读取 IP 时没有检查地址是否为空 SRS 3.0 does not check if the address is empty when reading IP. Jul 28, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug It might be a bug. TransByAI Translated by AI/GPT.
Projects
None yet
Development

No branches or pull requests

3 participants