mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 23:42:34 +00:00
Permit -dd; print a useful error message when single character options appear to be merged
This commit is contained in:
parent
fbd72c295d
commit
710c54a254
3 changed files with 71 additions and 15 deletions
17
CHANGES
17
CHANGES
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
corrections:
|
Corrections:
|
||||||
Makefile.in did not specify dependencies of filan on vsnprintf_r.o
|
Makefile.in did not specify dependencies of filan on vsnprintf_r.o
|
||||||
and snprinterr.o
|
and snprinterr.o
|
||||||
Added definition of FILAN_OBJS
|
Added definition of FILAN_OBJS
|
||||||
|
@ -55,7 +55,11 @@ corrections:
|
||||||
TCP6:127.0.0.1:80
|
TCP6:127.0.0.1:80
|
||||||
Thanks to Nicolas Fournil for reporting this issue.
|
Thanks to Nicolas Fournil for reporting this issue.
|
||||||
|
|
||||||
porting:
|
Print a useful error message when single character options appear to be
|
||||||
|
merged in Socat invocation
|
||||||
|
Test: SOCCAT_OPT_HINT
|
||||||
|
|
||||||
|
Porting:
|
||||||
OpenSSL functions TLS1_client_method() and similar are
|
OpenSSL functions TLS1_client_method() and similar are
|
||||||
deprecated. Socat now uses recommended TLS_client_method(). The old
|
deprecated. Socat now uses recommended TLS_client_method(). The old
|
||||||
functions and dependend option openssl-method can still be
|
functions and dependend option openssl-method can still be
|
||||||
|
@ -66,7 +70,7 @@ porting:
|
||||||
to make them better portable to systems without /bin/bash
|
to make them better portable to systems without /bin/bash
|
||||||
Thanks to Maya Rashish for sending a patch
|
Thanks to Maya Rashish for sending a patch
|
||||||
|
|
||||||
testing:
|
Testing:
|
||||||
test.sh: Show a warning when phase-1 (insecure phase) of a security
|
test.sh: Show a warning when phase-1 (insecure phase) of a security
|
||||||
test fails
|
test fails
|
||||||
|
|
||||||
|
@ -84,14 +88,17 @@ testing:
|
||||||
ip and ss.
|
ip and ss.
|
||||||
Thanks to Ruediger Meier for reporting this problem.
|
Thanks to Ruediger Meier for reporting this problem.
|
||||||
|
|
||||||
git:
|
Git:
|
||||||
Added missing Config/Makefile.DragonFly-2-8-2,
|
Added missing Config/Makefile.DragonFly-2-8-2,
|
||||||
Config/config.DragonFly-2-8-2.h
|
Config/config.DragonFly-2-8-2.h
|
||||||
Removed testcert.conf (to be generated by test.sh)
|
Removed testcert.conf (to be generated by test.sh)
|
||||||
|
|
||||||
cosmetics:
|
Cosmetics:
|
||||||
Simplified handling of missing termios defines.
|
Simplified handling of missing termios defines.
|
||||||
|
|
||||||
|
New features:
|
||||||
|
Permit combined -d options as -dd etc.
|
||||||
|
|
||||||
####################### V 1.7.3.2:
|
####################### V 1.7.3.2:
|
||||||
|
|
||||||
corrections:
|
corrections:
|
||||||
|
|
45
socat.c
45
socat.c
|
@ -53,6 +53,7 @@ struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
void socat_usage(FILE *fd);
|
void socat_usage(FILE *fd);
|
||||||
|
void socat_opt_hint(FILE *fd, char a, char b);
|
||||||
void socat_version(FILE *fd);
|
void socat_version(FILE *fd);
|
||||||
int socat(const char *address1, const char *address2);
|
int socat(const char *address1, const char *address2);
|
||||||
int _socat(void);
|
int _socat(void);
|
||||||
|
@ -108,7 +109,8 @@ int main(int argc, const char *argv[]) {
|
||||||
arg1 = argv+1; --argc;
|
arg1 = argv+1; --argc;
|
||||||
while (arg1[0] && (arg1[0][0] == '-')) {
|
while (arg1[0] && (arg1[0][0] == '-')) {
|
||||||
switch (arg1[0][1]) {
|
switch (arg1[0][1]) {
|
||||||
case 'V': socat_version(stdout); Exit(0);
|
case 'V': if (arg1[0][2]) { socat_usage(stderr); Exit(1); }
|
||||||
|
socat_version(stdout); Exit(0);
|
||||||
#if WITH_HELP
|
#if WITH_HELP
|
||||||
case '?':
|
case '?':
|
||||||
case 'h':
|
case 'h':
|
||||||
|
@ -116,9 +118,21 @@ int main(int argc, const char *argv[]) {
|
||||||
xioopenhelp(stdout, (arg1[0][2]=='?'||arg1[0][2]=='h') ? (arg1[0][3]=='?'||arg1[0][3]=='h') ? 2 : 1 : 0);
|
xioopenhelp(stdout, (arg1[0][2]=='?'||arg1[0][2]=='h') ? (arg1[0][3]=='?'||arg1[0][3]=='h') ? 2 : 1 : 0);
|
||||||
Exit(0);
|
Exit(0);
|
||||||
#endif /* WITH_HELP */
|
#endif /* WITH_HELP */
|
||||||
case 'd': diag_set('d', NULL); break;
|
case 'd':
|
||||||
|
a = *arg1+1;
|
||||||
|
while (*a) {
|
||||||
|
if (*a == 'd') {
|
||||||
|
diag_set('d', NULL);
|
||||||
|
} else {
|
||||||
|
socat_usage(stderr);
|
||||||
|
Exit(1);
|
||||||
|
}
|
||||||
|
++a;
|
||||||
|
}
|
||||||
|
break;
|
||||||
#if WITH_FILAN
|
#if WITH_FILAN
|
||||||
case 'D': socat_opts.debug = true; break;
|
case 'D': if (arg1[0][2]) { socat_opt_hint(stderr, arg1[0][1], arg1[0][2]); Exit(1); }
|
||||||
|
socat_opts.debug = true; break;
|
||||||
#endif
|
#endif
|
||||||
case 'l':
|
case 'l':
|
||||||
switch (arg1[0][2]) {
|
switch (arg1[0][2]) {
|
||||||
|
@ -156,8 +170,10 @@ int main(int argc, const char *argv[]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'v': socat_opts.verbose = true; break;
|
case 'v': if (arg1[0][2]) { socat_opt_hint(stderr, arg1[0][1], arg1[0][2]); Exit(1); }
|
||||||
case 'x': socat_opts.verbhex = true; break;
|
socat_opts.verbose = true; break;
|
||||||
|
case 'x': if (arg1[0][2]) { socat_opt_hint(stderr, arg1[0][1], arg1[0][2]); Exit(1); }
|
||||||
|
socat_opts.verbhex = true; break;
|
||||||
case 'b': if (arg1[0][2]) {
|
case 'b': if (arg1[0][2]) {
|
||||||
a = *arg1+2;
|
a = *arg1+2;
|
||||||
} else {
|
} else {
|
||||||
|
@ -169,7 +185,7 @@ int main(int argc, const char *argv[]) {
|
||||||
}
|
}
|
||||||
socat_opts.bufsiz = strtoul(a, (char **)&a, 0);
|
socat_opts.bufsiz = strtoul(a, (char **)&a, 0);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's': if (arg1[0][2]) { socat_opt_hint(stderr, arg1[0][1], arg1[0][2]); Exit(1); }
|
||||||
diag_set_int('e', E_FATAL); break;
|
diag_set_int('e', E_FATAL); break;
|
||||||
case 't': if (arg1[0][2]) {
|
case 't': if (arg1[0][2]) {
|
||||||
a = *arg1+2;
|
a = *arg1+2;
|
||||||
|
@ -199,9 +215,12 @@ int main(int argc, const char *argv[]) {
|
||||||
socat_opts.total_timeout.tv_usec =
|
socat_opts.total_timeout.tv_usec =
|
||||||
(rto-socat_opts.total_timeout.tv_sec) * 1000000;
|
(rto-socat_opts.total_timeout.tv_sec) * 1000000;
|
||||||
break;
|
break;
|
||||||
case 'u': socat_opts.lefttoright = true; break;
|
case 'u': if (arg1[0][2]) { socat_opt_hint(stderr, arg1[0][1], arg1[0][2]); Exit(1); }
|
||||||
case 'U': socat_opts.righttoleft = true; break;
|
socat_opts.lefttoright = true; break;
|
||||||
case 'g': xioopts_ignoregroups = true; break;
|
case 'U': if (arg1[0][2]) { socat_opt_hint(stderr, arg1[0][1], arg1[0][2]); Exit(1); }
|
||||||
|
socat_opts.righttoleft = true; break;
|
||||||
|
case 'g': if (arg1[0][2]) { socat_opt_hint(stderr, arg1[0][1], arg1[0][2]); Exit(1); }
|
||||||
|
xioopts_ignoregroups = true; break;
|
||||||
case 'L': if (socat_opts.lock.lockfile)
|
case 'L': if (socat_opts.lock.lockfile)
|
||||||
Error("only one -L and -W option allowed");
|
Error("only one -L and -W option allowed");
|
||||||
if (arg1[0][2]) {
|
if (arg1[0][2]) {
|
||||||
|
@ -236,6 +255,7 @@ int main(int argc, const char *argv[]) {
|
||||||
#if WITH_IP6
|
#if WITH_IP6
|
||||||
case '6':
|
case '6':
|
||||||
#endif
|
#endif
|
||||||
|
if (arg1[0][2]) { socat_opt_hint(stderr, arg1[0][1], arg1[0][2]); Exit(1); }
|
||||||
xioopts.default_ip = arg1[0][1];
|
xioopts.default_ip = arg1[0][1];
|
||||||
xioopts.preferred_ip = arg1[0][1];
|
xioopts.preferred_ip = arg1[0][1];
|
||||||
break;
|
break;
|
||||||
|
@ -333,7 +353,7 @@ void socat_usage(FILE *fd) {
|
||||||
fputs(" -hh like -h, plus a list of all common address option names\n", fd);
|
fputs(" -hh like -h, plus a list of all common address option names\n", fd);
|
||||||
fputs(" -hhh like -hh, plus a list of all available address option names\n", fd);
|
fputs(" -hhh like -hh, plus a list of all available address option names\n", fd);
|
||||||
#endif /* WITH_HELP */
|
#endif /* WITH_HELP */
|
||||||
fputs(" -d increase verbosity (use up to 4 times; 2 are recommended)\n", fd);
|
fputs(" -d[ddd] increase verbosity (use up to 4 times; 2 are recommended)\n", fd);
|
||||||
#if WITH_FILAN
|
#if WITH_FILAN
|
||||||
fputs(" -D analyze file descriptors before loop\n", fd);
|
fputs(" -D analyze file descriptors before loop\n", fd);
|
||||||
#endif
|
#endif
|
||||||
|
@ -363,6 +383,11 @@ void socat_usage(FILE *fd) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void socat_opt_hint(FILE *fd, char a, char b) {
|
||||||
|
fprintf(fd, "Do not merge single character options, i.e. use \"-%c -%c\" instead of \"-%c%c\"\n",
|
||||||
|
a, b, a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void socat_version(FILE *fd) {
|
void socat_version(FILE *fd) {
|
||||||
struct utsname ubuf;
|
struct utsname ubuf;
|
||||||
|
|
24
test.sh
24
test.sh
|
@ -12950,6 +12950,30 @@ PORT=$((PORT+1))
|
||||||
N=$((N+1))
|
N=$((N+1))
|
||||||
|
|
||||||
|
|
||||||
|
NAME=SOCAT_OPT_HINT
|
||||||
|
case "$TESTS" in
|
||||||
|
*%$N%*|*%socat%*|*%$NAME%*)
|
||||||
|
TEST="$NAME: check if merging single character options is rejected"
|
||||||
|
if ! eval $NUMCOND; then :; else
|
||||||
|
te="$td/test$N.stderr"
|
||||||
|
CMD0="$TRACE $SOCAT $opts -vx FILE:/dev/null ECHO"
|
||||||
|
printf "test $F_n $TEST... " $N
|
||||||
|
$CMD0 >/dev/null 2>"${te}0"
|
||||||
|
rc0=$?
|
||||||
|
if [ "$rc0" = "1" ]; then
|
||||||
|
$PRINTF "$OK\n"
|
||||||
|
numOK=$((numOK+1))
|
||||||
|
else
|
||||||
|
$PRINTF "$FAILED\n"
|
||||||
|
echo "$CMD0" >&2
|
||||||
|
numFAIL=$((numFAIL+1))
|
||||||
|
listFAIL="$listFAIL $N"
|
||||||
|
fi
|
||||||
|
fi ;; # NUMCOND
|
||||||
|
esac
|
||||||
|
N=$((N+1))
|
||||||
|
|
||||||
|
|
||||||
##################################################################################
|
##################################################################################
|
||||||
#=================================================================================
|
#=================================================================================
|
||||||
# here come tests that might affect your systems integrity. Put normal tests
|
# here come tests that might affect your systems integrity. Put normal tests
|
||||||
|
|
Loading…
Reference in a new issue