Repository navigation
[Device, kindle] early return if kindleGetCurrentProfile() is nil - #14219
Conversation
|
The (And, well, honor that bit of API in case of errors here, too). |
|
c.f., koreader/frontend/ui/network/wpa_supplicant.lua Lines 197 to 217 in bd2e33e Which would imply we just need a nil guard, but we should be able to return |
| if not kindleGetCurrentProfile() then return {} end | ||
| return { ssid = kindleGetCurrentProfile().essid } |
There was a problem hiding this comment.
| if not kindleGetCurrentProfile() then return {} end | |
| return { ssid = kindleGetCurrentProfile().essid } | |
| local nw = kindleGetCurrentProfile() | |
| if nw ~= nil then | |
| return { ssid = nw.essid } | |
| end |
There was a problem hiding this comment.
Something along those lines (untested).
There was a problem hiding this comment.
Possibly with fancy debug logging like the WpaClient imp ;o).
There was a problem hiding this comment.
fancy enough now?
| local nw = kindleGetCurrentProfile() | ||
| if nw ~= nil then | ||
| logger.dbg("NetworkMgr:getCurrentNetwork: Current network found") | ||
| return { ssid = nw.essid } | ||
| end | ||
| logger.dbg("NetworkMgr:getCurrentNetwork: No current network profile found") | ||
| return nil |
There was a problem hiding this comment.
Don't we normally do this the other way around? (if nil then early return, continue with non-nil)
There was a problem hiding this comment.
I thought about that, but I didn't want to make @NiLuJe angry ;)
There was a problem hiding this comment.
Yeah, agreed; the layout in WpaClient is weird for some reason ;).
| logger.dbg("NetworkMgr:getCurrentNetwork: No current network profile found") | ||
| return nil | ||
| end | ||
| logger.dbg("NetworkMgr:getCurrentNetwork: Current network found") |
There was a problem hiding this comment.
This could even print nw (or possibly just nw.essid, since IIRC that's the only key in there anyway) ;o).
There was a problem hiding this comment.
is there any potentially incriminating info there, we should be privacy conscious no?
There was a problem hiding this comment.
It's an SSID; if people are worried about that, they're probably in the wrong place ;).
There was a problem hiding this comment.
fun fact: I have seen people with SSIDs that include their [partial] address and/or family names, no joke. Do we really gain anything from knowing Little Timmy's "stay off my wifi"?
| return { ssid = kindleGetCurrentProfile().essid } | ||
| local nw = kindleGetCurrentProfile() | ||
| if nw == nil then | ||
| logger.dbg("NetworkMgr:getCurrentNetwork: No current network profile found") |
There was a problem hiding this comment.
The one says profile and the other doesn't. 👼
bug fix
NetworkMgr:getCurrentNetwork()to safely return an empty table ifkindleGetCurrentProfile()is nil, preventing possible nil dereference issues.@NiLuJe needs to bless this one.
fixes #14215
This change is