summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-25 15:24:09 +0100
committerStefan Schmidt <s.schmidt@samsung.com>2020-03-25 17:28:55 +0100
commit30057bd2f7307c5a32206b47d86615f899f1585a (patch)
tree98ba3fa67311b45e877ee9798c81f4dbb2018c1b
parent9330861f1242a923200a6e52e778401a8f30df9a (diff)
exactness: handbuild a new argv array instead of reassemling the new onedevs/stefan/exactnes-marcel
this commit removes the code that was changing argv values, and replaces it with a new array. Which is absolutly fine, as the argv / argc values are never accessed later on. Only the copies that have been passed to efl_main or elm_main. This resolves several issues: 1. the for loop is useless, every single array element that gets initialized with it, is some offset from argv[0] this may also crash when argv[i] - argv[opt_args] is bigger strlen argv[0]. 2. The memcpy here is super dangerous, the dest array is not garanteed to have the same size as argv[0], this only works if the client application name is shorter than the name "exactness_recorder" 3. The memset here is absolutly wrong. There is again no garantee that the array has the expected size behind that, this was constantly overwriting the segment after the place where argv was stored, which was lukely enough on fedora always the environs, which deleted the couple first segments. (This was not causing any fuzz, since they have been sudo related env vars on the docker image). However, on arch this just crashed right away. On Ubuntu this overwrote DISPLAY, which resulted in the unability to launch the app. Differential Revision: https://phab.enlightenment.org/D11600
-rw-r--r--src/bin/exactness/player.c23
-rw-r--r--src/bin/exactness/recorder.c21
2 files changed, 20 insertions, 24 deletions
diff --git a/src/bin/exactness/player.c b/src/bin/exactness/player.c
index 1d27863299..bb05f7aeb3 100644
--- a/src/bin/exactness/player.c
+++ b/src/bin/exactness/player.c
@@ -1082,24 +1082,23 @@ int main(int argc, char **argv)
1082 setenv("FONTCONFIG_FILE", fonts_conf_name, 1); 1082 setenv("FONTCONFIG_FILE", fonts_conf_name, 1);
1083 } 1083 }
1084 } 1084 }
1085 char **new_argv = argv;
1086 int new_argc = argc;
1085 1087
1086 if (argv[opt_args]) 1088 if (argv[opt_args])
1087 { 1089 {
1088 /* Replace the current command line to hide the Exactness part */ 1090 /* Replace the current command line to hide the Exactness part */
1089 int len = argv[argc - 1] + strlen(argv[argc - 1]) - argv[opt_args];
1090 memcpy(argv[0], argv[opt_args], len);
1091 memset(argv[0] + len, 0, CMD_LINE_MAX - len);
1092 1091
1093 int i; 1092 new_argv = calloc(argc - opt_args + 1, sizeof(char*));
1094 for (i = opt_args; i < argc; i++) 1093 new_argc = argc - opt_args;
1094
1095 for (int i = 0; i < argc - opt_args + 1; ++i)
1095 { 1096 {
1096 if (i != opt_args) 1097 if (i < argc - opt_args)
1097 { 1098 new_argv[i] = argv[opt_args + i];
1098 argv[i - opt_args] = argv[0] + (argv[i] - argv[opt_args]); 1099 else
1099 } 1100 new_argv[i] = NULL;
1100 INF("%s ", argv[i - opt_args]);
1101 } 1101 }
1102 INF("\n");
1103 } 1102 }
1104 else 1103 else
1105 { 1104 {
@@ -1142,7 +1141,7 @@ int main(int argc, char **argv)
1142 ecore_evas_callback_new_set(_my_evas_new); 1141 ecore_evas_callback_new_set(_my_evas_new);
1143 if (_src_type != FTYPE_REMOTE) 1142 if (_src_type != FTYPE_REMOTE)
1144 ecore_idler_add(_src_feed, NULL); 1143 ecore_idler_add(_src_feed, NULL);
1145 pret = ex_prg_invoke(ex_prg_full_path_guess(argv[0]), argc - opt_args, argv, EINA_TRUE); 1144 pret = ex_prg_invoke(ex_prg_full_path_guess(new_argv[0]), new_argc, new_argv, EINA_TRUE);
1146 1145
1147 if (_dest && _dest_unit) 1146 if (_dest && _dest_unit)
1148 { 1147 {
diff --git a/src/bin/exactness/recorder.c b/src/bin/exactness/recorder.c
index 11f5bfb1ec..9a33a57c4c 100644
--- a/src/bin/exactness/recorder.c
+++ b/src/bin/exactness/recorder.c
@@ -381,27 +381,24 @@ int main(int argc, char **argv)
381 } 381 }
382 382
383 /* Replace the current command line to hide the Exactness part */ 383 /* Replace the current command line to hide the Exactness part */
384 int len = argv[argc - 1] + strlen(argv[argc - 1]) - argv[opt_args]; 384 char **new_argv;
385 memcpy(argv[0], argv[opt_args], len);
386 memset(argv[0] + len, 0, PATH_MAX - len);
387 385
388 int i; 386 new_argv = calloc(argc - opt_args + 1, sizeof(char*));
389 for (i = opt_args; i < argc; i++) 387
388 for (int i = 0; i < argc - opt_args + 1; ++i)
390 { 389 {
391 if (i != opt_args) 390 if (i < argc - opt_args)
392 { 391 new_argv[i] = argv[opt_args + i];
393 argv[i - opt_args] = argv[0] + (argv[i] - argv[opt_args]); 392 else
394 } 393 new_argv[i] = NULL;
395 INF("%s ", argv[i - opt_args]);
396 } 394 }
397 INF("\n");
398 395
399 if (!_shot_key) _shot_key = getenv("SHOT_KEY"); 396 if (!_shot_key) _shot_key = getenv("SHOT_KEY");
400 if (!_shot_key) _shot_key = SHOT_KEY_STR; 397 if (!_shot_key) _shot_key = SHOT_KEY_STR;
401 398
402 ecore_evas_callback_new_set(_my_evas_new); 399 ecore_evas_callback_new_set(_my_evas_new);
403 _last_timestamp = ecore_time_get() * 1000; 400 _last_timestamp = ecore_time_get() * 1000;
404 pret = ex_prg_invoke(ex_prg_full_path_guess(argv[0]), argc - opt_args, argv, EINA_FALSE); 401 pret = ex_prg_invoke(ex_prg_full_path_guess(argv[opt_args]), argc - opt_args, new_argv, EINA_FALSE);
405 402
406 _output_write(); 403 _output_write();
407 //free_events(_events_list, EINA_TRUE); 404 //free_events(_events_list, EINA_TRUE);