Fix _build_date() crash on non-standard locale date strings#2701
Conversation
…ed#2513) Some Android devices return locale-dependent strings in ro.build.date (e.g. '2017年 11月 14日 星期二 09:55:07 CST' for Chinese locale) that dateutil.parser.parse() cannot handle, causing wait_for_device() to crash with a ParserError. Fix: prefer ro.build.date.utc (integer epoch timestamp) which is locale-independent and available on all Android devices. Fall back to ro.build.date with error handling if the UTC property is missing.
4e72660 to
fa8032a
Compare
|
If Can you link some docs stating it is available on all android devices please? |
Address review: ro.build.date.utc is set by the AOSP build system and available on all standard Android devices. Simplified comments to reflect this is the primary path, with ro.build.date kept only as a fallback for non-standard builds.
|
Good point —
I have updated the code to make |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Fixes pwnlib.adb.wait_for_device() crashing when ro.build.date is locale-dependent and not parseable by dateutil, by preferring the locale-independent ro.build.date.utc and adding safer fallbacks.
Changes:
- Prefer
ro.build.date.utc(epoch seconds) for build date formatting, with error-handled fallback toro.build.date. - Prevent hard-crash on unparsable
ro.build.dateby returning the raw string instead. - Add changelog entry for the fix.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
pwnlib/adb/adb.py |
Updates _build_date() to use ro.build.date.utc first and avoid dateutil crashes on non-standard locale strings. |
CHANGELOG.md |
Adds a stable-branch changelog entry and link reference for the fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
We can remove the |
The FTP server is throttled in CI or just really slow. We already test the basic tcp tubes in the `remote` tests.
Summary
Fixes #2513
pwnlib.adb.wait_for_device()crashes withdateutil.parser.ParserErroron Android devices that return locale-dependent strings inro.build.date(e.g. Chinese locale:2017年 11月 14日 星期二 09:55:07 CST).Fix
ro.build.date.utc(integer epoch timestamp) which is locale-independent and available on all Android devices, as suggested by @RocketMaDevro.build.datewith a try/except if the UTC property is missingdatetime.fromtimestamp()(no deprecation warnings)Target Branch
stable— this is a bugfix for existing released functionality.Testing
The fix is a simple fallback chain. The original code path (dateutil parsing) is preserved as a fallback, so existing behavior is unchanged for devices with standard date formats.