Skip to content

Commit

Permalink
Hotfix followup to koreader#10139
Browse files Browse the repository at this point in the history
Don't blow up if we fall back to exec'ing ping
Fix koreader#10139 (comment)
  • Loading branch information
NiLuJe committed Feb 21, 2023
1 parent 5330c24 commit 4c597a7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions frontend/device/generic/device.lua
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,9 @@ function Device:ping4(ip)
if socket == -1 then
errno = ffi.errno()
if errno == C.EPERM then
logger.dbg("Device:ping4: Opening a RAW ICMP socket requires CAP_NET_RAW capabilities!")
logger.dbg("Device:ping4: opening a RAW ICMP socket requires CAP_NET_RAW capabilities!")
else
logger.dbg("Device:ping4: Raw ICMP socket:", ffi.string(C.strerror(errno)))
logger.dbg("Device:ping4: raw ICMP socket:", ffi.string(C.strerror(errno)))
end
--- Fall-back to the ping CLI tool, in the hope that it's setuid...
if self:isKindle() and self:hasDPad() then
Expand Down Expand Up @@ -841,9 +841,11 @@ function Device:retrieveNetworkInfo()
if default_gw then
local ok, rtt = self:ping4(default_gw)
if ok then
rtt = string.format("%.3f", rtt * 1/1000) -- i.e., time.to_ms w/o flooring
table.insert(results, _("Gateway ping successful"))
table.insert(results, T(_("RTT: %1 ms"), rtt))
if rtt then
rtt = string.format("%.3f", rtt * 1/1000) -- i.e., time.to_ms w/o flooring
table.insert(results, T(_("RTT: %1 ms"), rtt))
end
else
table.insert(results, _("Gateway ping FAILED"))
if rtt then
Expand Down

0 comments on commit 4c597a7

Please sign in to comment.