Skip to content

Commit f0f381d

Browse files
committed
fix the bug of getting the valule of Gateway mistakenly from the valule of Destination
The /proc/net/route info on the device is always displayed like this: $cat /proc/net/route Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT eth0 00A6440A 00000000 0001 0 0 0 00FFFFFF 0 0 0 clearly, the 3rd vaule(Gateway) is what we want, but in the code as we can see, we always get the 2nd value(Destination), that's not right. I think the reason we didn't recognize this bug is that sometimes Destination can be '000000', but recently, a "failed to detect the external interface" err occured on my device , just cause the value of Destination is not "00000000"(but Gateway is "00000000", means this err should not happen). hope can help to fix this bug, thanks:) Signed-off-by: hongze zhu <[email protected]>
1 parent 39d502b commit f0f381d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ get_ext_iface(void)
252252
}
253253
while (!feof(input)) {
254254
/* XXX scanf(3) is unsafe, risks overrun */
255-
if ((fscanf(input, "%15s %15s %*s %*s %*s %*s %*s %*s %*s %*s %*s\n", device, gw) == 2)
255+
if ((fscanf(input, "%15s %*s %15s %*s %*s %*s %*s %*s %*s %*s %*s\n", device, gw) == 2)
256256
&& strcmp(gw, "00000000") == 0) {
257257
free(gw);
258258
debug(LOG_INFO, "get_ext_iface(): Detected %s as the default interface after trying %d", device, i);

0 commit comments

Comments
 (0)