At https://github.com/al45tair/netifaces/blob/b8662eca722ee3417c433468cb6041440d0af8c9/netifaces.c#L2010, gateways() will loop if the condition ret != 0 || errno == ENOMEM || errno == EINTR is true. However, that condition is invalid. If ret is 0, then errno is undefined. It may contain a value leftover from the caller of gateways, or it may contain an error that was internally handled by sysctl(3). Also, the fact that the very next line checks for negative values of ret implies that the condtion is wrong; as-is, ret can never be negative at that point. The condition should probably read ret != 0 && (errno == ENOMEM || errno == EINTR).
At https://github.com/al45tair/netifaces/blob/b8662eca722ee3417c433468cb6041440d0af8c9/netifaces.c#L2010, gateways() will loop if the condition
ret != 0 || errno == ENOMEM || errno == EINTR
is true. However, that condition is invalid. Ifret
is 0, thenerrno
is undefined. It may contain a value leftover from the caller ofgateways
, or it may contain an error that was internally handled by sysctl(3). Also, the fact that the very next line checks for negative values ofret
implies that the condtion is wrong; as-is,ret
can never be negative at that point. The condition should probably readret != 0 && (errno == ENOMEM || errno == EINTR)
.I think this is the root cause of https://github.com/iocage/iocage/issues/766 .