Skip to content
This repository was archived by the owner on Jul 27, 2024. It is now read-only.

const_string_encryption: Fix problem where static constructor not correctly found#98

Merged
ClaudiuGeorgiu merged 1 commit intoClaudiuGeorgiu:masterfrom
techee:static_constructor_fix
May 30, 2021
Merged

const_string_encryption: Fix problem where static constructor not correctly found#98
ClaudiuGeorgiu merged 1 commit intoClaudiuGeorgiu:masterfrom
techee:static_constructor_fix

Conversation

@techee
Copy link
Copy Markdown
Contributor

@techee techee commented May 28, 2021

The current code expects that static constructors are declared as:

.method static constructor ()V

However, static constructors in smali files may contain the "public" keyword
so the static constructor has the form:

.method public static constructor ()V

The current code doesn't find such constructors and inserts another
static constructor to the code instead so there are 2 static constructors.
Smali seems to use only the first declared constructor (with the string
initializers) and ignores the second one with the original initialization
code which leads to uninitialized static members.

This patch simply relaxes the check of static constructors so there
can be an arbitrary string (including empty string) between ".method"
and "static".

…rectly found

The current code expects that static constructors are declared as:

.method static constructor <clinit>()V

However, static constructors in smali files may contain the "public" keyword
so the static constructor has the form:

.method public static constructor <clinit>()V

The current code doesn't find such constructors and inserts another
static constructor to the code instead so there are 2 static constructors.
Smali seems to use only the first declared constructor (with the string
initializers) and ignores the second one with the original initialization
code which leads to uninitialized static members.

This patch simply relaxes the check of static constructors so there
can be an arbitrary string (including empty string) between ".method"
and "static".
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2021

Codecov Report

Merging #98 (31ee0f9) into master (8637197) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #98   +/-   ##
=======================================
  Coverage   77.57%   77.57%           
=======================================
  Files          49       49           
  Lines        2453     2453           
  Branches      486      486           
=======================================
  Hits         1903     1903           
  Misses        422      422           
  Partials      128      128           
Impacted Files Coverage Δ
...const_string_encryption/const_string_encryption.py 85.29% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8637197...31ee0f9. Read the comment docs.

@ClaudiuGeorgiu ClaudiuGeorgiu merged commit f1122f0 into ClaudiuGeorgiu:master May 30, 2021
@ClaudiuGeorgiu
Copy link
Copy Markdown
Owner

Thanks @techee!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants