Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Sunxi Tools
Commits
29c63621
Commit
29c63621
authored
Nov 11, 2016
by
NiteHawk
Committed by
GitHub
Nov 11, 2016
Browse files
Merge pull request #80 from n1tehawk/contrib
fexc: Fix .bin header treatment, improve .fex parser
parents
bf735b2c
2e6697b2
Changes
3
Show whitespace changes
Inline
Side-by-side
script_bin.c
View file @
29c63621
...
@@ -97,7 +97,7 @@ size_t script_bin_size(struct script *script,
...
@@ -97,7 +97,7 @@ size_t script_bin_size(struct script *script,
return
bin_size
;
return
bin_size
;
}
}
int
script_generate_bin
(
void
*
bin
,
size_t
UNUSED
(
bin_size
)
,
int
script_generate_bin
(
void
*
bin
,
size_t
bin_size
,
struct
script
*
script
,
struct
script
*
script
,
size_t
sections
,
size_t
entries
)
size_t
sections
,
size_t
entries
)
{
{
...
@@ -122,9 +122,9 @@ int script_generate_bin(void *bin, size_t UNUSED(bin_size),
...
@@ -122,9 +122,9 @@ int script_generate_bin(void *bin, size_t UNUSED(bin_size),
(
void
*
)
data
-
bin
);
(
void
*
)
data
-
bin
);
head
->
sections
=
sections
;
head
->
sections
=
sections
;
head
->
version
[
0
]
=
0
;
head
->
filesize
=
bin_size
;
head
->
version
[
1
]
=
1
;
head
->
version
[
0
]
=
1
;
head
->
version
[
2
]
=
2
;
head
->
version
[
1
]
=
2
;
for
(
ls
=
list_first
(
&
script
->
sections
);
ls
;
for
(
ls
=
list_first
(
&
script
->
sections
);
ls
;
ls
=
list_next
(
&
script
->
sections
,
ls
))
{
ls
=
list_next
(
&
script
->
sections
,
ls
))
{
...
@@ -326,11 +326,10 @@ int script_decompile_bin(void *bin, size_t bin_size,
...
@@ -326,11 +326,10 @@ int script_decompile_bin(void *bin, size_t bin_size,
unsigned
int
i
;
unsigned
int
i
;
struct
script_bin_head
*
head
=
bin
;
struct
script_bin_head
*
head
=
bin
;
if
(((
head
->
version
[
0
]
&
0x3FFF
)
>
SCRIPT_BIN_VERSION_LIMIT
)
||
if
((
head
->
version
[
0
]
>
SCRIPT_BIN_VERSION_LIMIT
)
||
(
head
->
version
[
1
]
>
SCRIPT_BIN_VERSION_LIMIT
)
||
(
head
->
version
[
1
]
>
SCRIPT_BIN_VERSION_LIMIT
))
{
(
head
->
version
[
2
]
>
SCRIPT_BIN_VERSION_LIMIT
))
{
pr_err
(
"Malformed data: version %u.%u.
\n
"
,
pr_err
(
"Malformed data: version %u.%u.%u.
\n
"
,
head
->
version
[
0
],
head
->
version
[
1
]);
head
->
version
[
0
],
head
->
version
[
1
],
head
->
version
[
2
]);
return
0
;
return
0
;
}
}
...
@@ -340,10 +339,10 @@ int script_decompile_bin(void *bin, size_t bin_size,
...
@@ -340,10 +339,10 @@ int script_decompile_bin(void *bin, size_t bin_size,
return
0
;
return
0
;
}
}
pr_info
(
"%s: version: %u.%u
.%u
\n
"
,
filename
,
pr_info
(
"%s: version: %u.%u
\n
"
,
filename
,
head
->
version
[
0
]
&
0x3FFF
,
head
->
version
[
1
]
,
head
->
version
[
2
]
);
head
->
version
[
0
],
head
->
version
[
1
]);
pr_info
(
"%s: size: %zu (%u sections)
\n
"
,
filename
,
pr_info
(
"%s: size: %zu (%u sections)
, header value: %u
\n
"
,
filename
,
bin_size
,
head
->
sections
);
bin_size
,
head
->
sections
,
head
->
filesize
);
/* TODO: SANITY: compare head.sections with bin_size */
/* TODO: SANITY: compare head.sections with bin_size */
for
(
i
=
0
;
i
<
head
->
sections
;
i
++
)
{
for
(
i
=
0
;
i
<
head
->
sections
;
i
++
)
{
...
...
script_bin.h
View file @
29c63621
...
@@ -27,7 +27,8 @@ struct script_bin_section {
...
@@ -27,7 +27,8 @@ struct script_bin_section {
/** binary representation of the head of the script file */
/** binary representation of the head of the script file */
struct
script_bin_head
{
struct
script_bin_head
{
uint32_t
sections
;
uint32_t
sections
;
uint32_t
version
[
3
];
uint32_t
filesize
;
uint32_t
version
[
2
];
struct
script_bin_section
section
[];
struct
script_bin_section
section
[];
};
};
...
...
script_fex.c
View file @
29c63621
...
@@ -348,7 +348,15 @@ int script_parse_fex(FILE *in, const char *filename, struct script *script)
...
@@ -348,7 +348,15 @@ int script_parse_fex(FILE *in, const char *filename, struct script *script)
continue
;
continue
;
}
}
}
else
{
}
else
{
goto
invalid_char_at_p
;
/* goto invalid_char_at_p; */
errf
(
"Warning: %s:%zu: unquoted value '%s', assuming string
\n
"
,
filename
,
line
,
p
);
if
(
script_string_entry_new
(
last_section
,
key
,
pe
-
p
,
p
))
{
pr_debug
(
"%s.%s =
\"
%s
\"\n
"
,
last_section
->
name
,
key
,
p
);
continue
;
}
perror
(
"malloc"
);
}
}
errf
(
"E: %s:%zu: parse error at %zu.
\n
"
,
errf
(
"E: %s:%zu: parse error at %zu.
\n
"
,
filename
,
line
,
p
-
buffer
+
1
);
filename
,
line
,
p
-
buffer
+
1
);
...
...
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