diff options
author | José Fonseca <jfonseca@vmware.com> | 2014-10-03 14:07:47 +0100 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2014-10-03 14:07:47 +0100 |
commit | bb03587047c586097d1aecaba112de325093a93f (patch) | |
tree | ab833560efed366ffaa15f1936967d4db40216bb | |
parent | 4bc3cfde42118081268690217172d7b577867c65 (diff) |
inject: Don't mistakenly recognise commands that start with a digit as process ids.
-rw-r--r-- | inject/injector.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/inject/injector.cpp b/inject/injector.cpp index deda980e..4087e2cd 100644 --- a/inject/injector.cpp +++ b/inject/injector.cpp @@ -276,6 +276,17 @@ getProcessIdByName(const char *szProcessName, DWORD *pdwProcessID) } +static bool +isNumber(const char *arg) { + while (*arg) { + if (!isdigit(*arg++)) { + return false; + } + } + return true; +} + + int main(int argc, char *argv[]) { @@ -291,7 +302,7 @@ main(int argc, char *argv[]) BOOL bAttach = FALSE; DWORD dwProcessId = ~0; - if (isdigit(argv[2][0])) { + if (isNumber(argv[2])) { dwProcessId = atol(argv[2]); bAttach = TRUE; } else if (argv[2][0] == '!') { |