Skip to content

Commit da3c4b6

Browse files
committed
fix: improve exception handling in process.py and adb.py
- process.py: restore bare except with pylint disable (intentional: catches non-Exception errors during Python interpreter shutdown) - adb.py: use specific (OSError, EOFError) instead of broad except Exception
1 parent 57de79f commit da3c4b6

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

pwnlib/adb/adb.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ def __do_deferred_initialization(self):
320320
r.recvline() # Rest of the line
321321
r.sendline('avd name')
322322
self.avd = r.recvline().strip()
323-
except:
323+
except (OSError, EOFError) as e:
324+
# ADB device disconnected or not responding, skip AVD name lookup
324325
pass
325326

326327
self._initialized = True

pwnlib/tubes/process.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,8 @@ def _read_in_thread(recv_queue, proc_stdout):
16481648
recv_queue.put(b)
16491649
else:
16501650
break
1651-
except:
1652-
# Ignore any errors during Python shutdown
1651+
except: # pylint: disable=bare-except
1652+
# Ignore any errors during Python shutdown.
1653+
# Bare except is intentional: during interpreter shutdown,
1654+
# IO operations can raise non-Exception BaseException subclasses.
16531655
pass

0 commit comments

Comments
 (0)