mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
If you have trouble updating after this revision you need to follow these instructions. You have probably just seen an error like this: svn: URL 'svn://svn.insecure.org/nping' of existing directory 'nping' does not match expected URL 'svn://svn.insecure.org/nmap/nping' This is caused by the replacement of SVN externals. Here's what you need to do. First, save any local changes you might have in the nping, nsock, nbase, ncat, and zenmap directories. (For example by running "cd nping; svn diff > ../nping.diff".) If you don't have any local changes you can skip this step. Then run these commands: rm -rf nping/ nsock/ nbase/ ncat/ zenmap/ svn update svn cleanup If all else fails, you can just delete your whole working directory and check out anew: svn co --username guest --password "" svn://svn.insecure.org/nmap There may be further discussion in the mailing list thread at http://seclists.org/nmap-dev/2011/q4/303.
101 lines
2.6 KiB
C
101 lines
2.6 KiB
C
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
static long test_count = 0;
|
|
static long success_count = 0;
|
|
char **cmdline_split(const char *cmdexec);
|
|
|
|
int test_cmdline(const char *line, const char **target_args)
|
|
{
|
|
char **cmd_args;
|
|
int args_match = 1;
|
|
|
|
test_count++;
|
|
|
|
cmd_args = cmdline_split(line);
|
|
|
|
/*
|
|
* Make sure that all of the target arguments are have been extracted
|
|
* by cmdline_split.
|
|
*/
|
|
while (*cmd_args && *target_args) {
|
|
if (strcmp(*cmd_args, *target_args)) {
|
|
args_match = 0;
|
|
break;
|
|
}
|
|
cmd_args++;
|
|
target_args++;
|
|
}
|
|
if ((*cmd_args != NULL) || (*target_args != NULL)) {
|
|
/*
|
|
* One of the argument list had more arguments than the other.
|
|
* Therefore, they do not match
|
|
*/
|
|
args_match = 0;
|
|
}
|
|
|
|
if (args_match) {
|
|
success_count++;
|
|
printf("PASS '%s'\n", line);
|
|
return 1;
|
|
} else {
|
|
printf("FAIL '%s'\n", line);
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
int test_cmdline_fail(const char *line)
|
|
{
|
|
char **cmd_args;
|
|
|
|
test_count++;
|
|
|
|
cmd_args = cmdline_split(line);
|
|
|
|
if (*cmd_args == NULL) {
|
|
success_count++;
|
|
printf("PASS '%s'\n", line);
|
|
return 1;
|
|
} else {
|
|
printf("PASS '%s'\n", line);
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int i;
|
|
|
|
struct {
|
|
const char *cmdexec;
|
|
const char *args[10];
|
|
} TEST_CASES[] = {
|
|
{"ncat -l -k", {"ncat", "-l", "-k", NULL}},
|
|
{"ncat localhost 793", {"ncat", "localhost", "793", NULL}},
|
|
{"./ncat scanme.nmap.org 80", {"./ncat", "scanme.nmap.org", "80",
|
|
NULL}},
|
|
{"t\\ p\\ s hello world how are you?", {"t p s", "hello", "world", "how", "are",
|
|
"you?", NULL}},
|
|
{"t\\ p\\ s hello world how\\ are you?", {"t p s", "hello", "world", "how are",
|
|
"you?", NULL}},
|
|
{"ncat\\", {"ncat", NULL}},
|
|
{"a\\nb", {"anb", NULL}},
|
|
{" ncat a ", {"ncat", "a", NULL}},
|
|
{"\\ncat \\a", {"ncat", "a", NULL}},
|
|
{"ncat\\\\ a", {"ncat\\", "a", NULL}},
|
|
{"ncat\\", {"ncat", NULL}},
|
|
{"ncat\\ \\", {"ncat ", NULL}},
|
|
};
|
|
|
|
for (i = 0; i < sizeof(TEST_CASES)/sizeof(TEST_CASES[0]); i++) {
|
|
test_cmdline(TEST_CASES[i].cmdexec,
|
|
TEST_CASES[i].args);
|
|
}
|
|
|
|
test_cmdline_fail("");
|
|
printf("%ld / %ld tests passed.\n", success_count, test_count);
|
|
return success_count == test_count ? 0 : 1;
|
|
}
|