From 91f056ab715834b0e822c5a23a4f5165a9ed02c3 Mon Sep 17 00:00:00 2001 From: Anders Borum Date: Mon, 29 Jan 2018 10:23:56 +0100 Subject: [PATCH] safer way to skip leading \ in arg move past leading '\\' for command arguments in a way that does not ruin it for free() --- ios_system.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ios_system.m b/ios_system.m index 79248041..c5385c84 100644 --- a/ios_system.m +++ b/ios_system.m @@ -892,7 +892,8 @@ int ios_system(const char* inputCmd) { // The executable file has precedence, unless the user has specified they want the original // version, by prefixing it with \. So "\ls" == always "our" ls. "ls" == maybe ~/Library/bin/ls // (if it exists). - argv[0] = argv[0] + 1; + size_t len_with_terminator = strlen(argv[0] + 1) + 1; + memmove(argv[0], argv[0] + 1, len_with_terminator); } else { NSString* commandName = [NSString stringWithCString:argv[0]]; BOOL isDir = false;