Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
fc4dcd2d
Commit
fc4dcd2d
authored
Jan 18, 2018
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: prevent some null crash on resource decoding
parent
4e07d80e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
ResXmlGen.java
jadx-core/src/main/java/jadx/core/xmlgen/ResXmlGen.java
+5
-2
ValuesParser.java
...re/src/main/java/jadx/core/xmlgen/entry/ValuesParser.java
+10
-4
No files found.
jadx-core/src/main/java/jadx/core/xmlgen/ResXmlGen.java
View file @
fc4dcd2d
...
...
@@ -64,7 +64,7 @@ public class ResXmlGen {
cw
.
startLine
();
cw
.
add
(
'<'
).
add
(
ri
.
getTypeName
()).
add
(
' '
);
String
itemTag
=
"item"
;
if
(
ri
.
getTypeName
().
equals
(
"attr"
)
&&
ri
.
getNamedValues
().
size
()
>
0
)
{
if
(
ri
.
getTypeName
().
equals
(
"attr"
)
&&
!
ri
.
getNamedValues
().
isEmpty
()
)
{
cw
.
add
(
"name=\""
).
add
(
ri
.
getKeyName
());
int
type
=
ri
.
getNamedValues
().
get
(
0
).
getRawValue
().
getData
();
if
((
type
&
ValuesParser
.
ATTR_TYPE_ENUM
)
!=
0
)
{
...
...
@@ -126,7 +126,7 @@ public class ResXmlGen {
String
nameStr
=
vp
.
decodeNameRef
(
value
.
getNameRef
());
String
valueStr
=
vp
.
decodeValue
(
value
.
getRawValue
());
if
(!
typeName
.
equals
(
"attr"
))
{
if
(
valueStr
.
equals
(
"0"
))
{
if
(
valueStr
==
null
||
valueStr
.
equals
(
"0"
))
{
valueStr
=
"@null"
;
}
if
(
nameStr
!=
null
)
{
...
...
@@ -154,6 +154,9 @@ public class ResXmlGen {
}
private
void
addSimpleValue
(
CodeWriter
cw
,
String
typeName
,
String
itemTag
,
String
attrName
,
String
attrValue
,
String
valueStr
)
{
if
(
valueStr
==
null
)
{
return
;
}
if
(
valueStr
.
startsWith
(
"res/"
))
{
// remove duplicated resources.
return
;
...
...
jadx-core/src/main/java/jadx/core/xmlgen/entry/ValuesParser.java
View file @
fc4dcd2d
package
jadx
.
core
.
xmlgen
.
entry
;
import
jadx.core.xmlgen.ParserConstants
;
import
jadx.core.xmlgen.ResTableParser
;
import
java.io.BufferedInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
...
...
@@ -11,9 +8,13 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.Map
;
import
org.jetbrains.annotations.Nullable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
jadx.core.xmlgen.ParserConstants
;
import
jadx.core.xmlgen.ResTableParser
;
public
class
ValuesParser
extends
ParserConstants
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ValuesParser
.
class
);
...
...
@@ -44,6 +45,7 @@ public class ValuesParser extends ParserConstants {
androidResMap
=
androidParser
.
getResStorage
().
getResourcesNames
();
}
@Nullable
public
String
getValueString
(
ResourceEntry
ri
)
{
RawValue
simpleValue
=
ri
.
getSimpleValue
();
if
(
simpleValue
!=
null
)
{
...
...
@@ -63,12 +65,14 @@ public class ValuesParser extends ParserConstants {
return
strList
.
toString
();
}
@Nullable
public
String
decodeValue
(
RawValue
value
)
{
int
dataType
=
value
.
getDataType
();
int
data
=
value
.
getData
();
return
decodeValue
(
dataType
,
data
);
}
@Nullable
public
String
decodeValue
(
int
dataType
,
int
data
)
{
switch
(
dataType
)
{
case
TYPE_NULL:
...
...
@@ -100,7 +104,9 @@ public class ValuesParser extends ParserConstants {
if
(
androidRi
!=
null
)
{
return
"@android:"
+
androidRi
;
}
if
(
data
==
0
)
return
"0"
;
if
(
data
==
0
)
{
return
"0"
;
}
return
"?unknown_ref: "
+
Integer
.
toHexString
(
data
);
}
return
"@"
+
ri
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment