Skip to content

Fix _build_date() crash on non-standard locale date strings#2701

Merged
peace-maker merged 7 commits intoGallopsled:stablefrom
coder999999999:fix/adb-build-date-locale-2513
Apr 7, 2026
Merged

Fix _build_date() crash on non-standard locale date strings#2701
peace-maker merged 7 commits intoGallopsled:stablefrom
coder999999999:fix/adb-build-date-locale-2513

Conversation

@coder999999999
Copy link
Copy Markdown
Contributor

Summary

Fixes #2513

pwnlib.adb.wait_for_device() crashes with dateutil.parser.ParserError on Android devices that return locale-dependent strings in ro.build.date (e.g. Chinese locale: 2017年 11月 14日 星期二 09:55:07 CST).

Fix

  • Prefer ro.build.date.utc (integer epoch timestamp) which is locale-independent and available on all Android devices, as suggested by @RocketMaDev
  • Fall back to ro.build.date with a try/except if the UTC property is missing
  • Uses timezone-aware datetime.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.

…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.
@coder999999999 coder999999999 force-pushed the fix/adb-build-date-locale-2513 branch from 4e72660 to fa8032a Compare March 23, 2026 02:38
@peace-maker
Copy link
Copy Markdown
Member

If ro.build.date.utc is available everywhere, I'd rather use that one and not care about the ro.build.date. That would allow us to drop the dateutil dependency just for this function.

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.
@coder999999999
Copy link
Copy Markdown
Contributor Author

Good point — ro.build.date.utc is set by the AOSP build system and has been part of every standard Android build since at least Android 5.0. The android.os.Build.TIME constant reads directly from it:

  • AOSP Build.java (android-5.0.0_r1)Build.TIME = SystemProperties.getLong("ro.build.date.utc", 0) * 1000
  • It is generated during the build process and written to build.prop on every device

I have updated the code to make ro.build.date.utc the primary (and expected) path, with clearer comments reflecting this. I kept a minimal ro.build.date fallback only for non-standard builds that might be missing the UTC property, but happy to drop it entirely if you prefer.

@RocketMaDev

This comment has been minimized.

Copilot AI review requested due to automatic review settings April 5, 2026 20:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 to ro.build.date.
  • Prevent hard-crash on unparsable ro.build.date by 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.

Comment thread pwnlib/adb/adb.py
Comment thread pwnlib/adb/adb.py
Comment thread CHANGELOG.md Outdated
@peace-maker
Copy link
Copy Markdown
Member

We can remove the dateutil dependency and ro.build.date fallback in dev since stable is supposed to still support Python 2.7 as Copilot reminded us politely.

The FTP server is throttled in CI or just really slow. We already test the basic tcp tubes in the `remote` tests.
@peace-maker peace-maker merged commit 43ef1b4 into Gallopsled:stable Apr 7, 2026
42 of 56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants