diff --git a/CHANGES b/CHANGES index 8bef34f..6c264e4 100644 --- a/CHANGES +++ b/CHANGES @@ -60,6 +60,10 @@ Corrections: now handled properly. Test: UNIX_L_BIND + Removed unused bytes variable from gettimestamp(), corrected #elsif and + socks4 record length. + Thanks to clang-18 and gcc-13. + Features: POSIXMQ-RECV now takes option o-nonblock; this, in combination with -T, makes it possible to terminate Socat in case the queue is empty. diff --git a/socat.c b/socat.c index 5886a00..567cd29 100644 --- a/socat.c +++ b/socat.c @@ -1339,7 +1339,6 @@ int _socat(void) { should be at least MAXTIMESTAMPLEN bytes long. returns 0 on success or -1 if an error occurred */ int gettimestamp(char *timestamp) { - size_t bytes; #if HAVE_CLOCK_GETTIME struct timespec now; #elif HAVE_PROTOTYPE_LIB_gettimeofday @@ -1367,17 +1366,16 @@ int gettimestamp(char *timestamp) { } #endif #if HAVE_STRFTIME - bytes = strftime(timestamp, 20, "%Y/%m/%d %H:%M:%S", localtime(&nowt)); + strftime(timestamp, 20, "%Y/%m/%d %H:%M:%S", localtime(&nowt)); #if HAVE_CLOCK_GETTIME - bytes += sprintf(timestamp+19, "."F_tv_nsec" ", now.tv_nsec/1000); + sprintf(timestamp+19, "."F_tv_nsec" ", now.tv_nsec/1000); #elif HAVE_PROTOTYPE_LIB_gettimeofday - bytes += sprintf(timestamp+19, "."F_tv_usec" ", now.tv_usec); + sprintf(timestamp+19, "."F_tv_usec" ", now.tv_usec); #else strncpy(×tamp[bytes++], " ", 2); #endif #else strcpy(timestamp, ctime(&nowt)); - bytes = strlen(timestamp); #endif return 0; } diff --git a/test.sh b/test.sh index 64e2158..0ed9584 100755 --- a/test.sh +++ b/test.sh @@ -15787,25 +15787,33 @@ te="$td/test$N.stderr" tdiff="$td/test$N.diff" da="test$N $(date) $RANDOM" CMD0="$TRACE $SOCAT $opts STDIO SYSTEM:'tee /dev/stdout 2>/dev/null',pty,cfmakeraw" -#set -vx -printf "test $F_n $TEST... " $N -{ echo "$da"; relsleep 10; } |eval "$CMD0" >"${tf}0" 2>"${te}0" & -pid0=$! -relsleep 2 TTY=$(tty |sed 's|/dev/||') -pkill -USR1 -t $TTY socat || { echo "pkill -t $TTY -USR1 socat"; } +CMD1="pkill -USR1 -t $TTY socat" +printf "test $F_n $TEST... " $N +# On Fedora-41 pkill can be slow (eg.20ms) +{ echo "$da"; relsleep 20; } |eval "$CMD0" >"${tf}0" 2>"${te}0" & +pid0=$! +#date +'%Y-%m-%dT%H:%M:%S.%N' >>"${te}1" relsleep 2 -pkill -t $TTY socat +#date +'%Y-%m-%dT%H:%M:%S.%N' >>"${te}1" +$CMD1 2>"${te}1" +relsleep 2 +#date +'%Y-%m-%dT%H:%M:%S.%N' >>"${te}1" wait +pkill -t $TTY socat >>"${te}1" if [ "$(grep STATISTICS "${te}0" |wc -l)" -eq 2 ]; then $PRINTF "$OK\n" - if [ "$VERBOSE" ]; then echo "$CMD0"; fi + if [ "$VERBOSE" ]; then echo "$CMD0 &"; fi if [ "$DEBUG" ]; then cat "${te}0" >&2; fi + if [ "$VERBOSE" ]; then echo "$CMD1"; fi + if [ "$DEBUG" ]; then cat "${te}1" >&2; fi ok else - $PRINTF "$FAILED\n" + $PRINTF "$FAILED (no stats)\n" echo "$CMD0 &" cat "${te}0" >&2 + echo "$CMD1" + cat "${te}1" >&2 failed fi fi # NUMCOND diff --git a/xio-ip.c b/xio-ip.c index c6b14df..a0c12c9 100644 --- a/xio-ip.c +++ b/xio-ip.c @@ -592,7 +592,7 @@ int _xiogetaddrinfo(const char *node, const char *service, freehostent(host); } -#elsif 0 /* !HAVE_PROTOTYPE_LIB_getipnodebyname */ +#elif 0 /* !HAVE_PROTOTYPE_LIB_getipnodebyname */ if (node != NULL) { /* this is not a typical IP6 resolver function - but Linux diff --git a/xio-socks.h b/xio-socks.h index b089ec2..f9a1131 100644 --- a/xio-socks.h +++ b/xio-socks.h @@ -10,9 +10,9 @@ struct socks4 { uint8_t action; uint16_t port; uint32_t dest; - char userid[1]; /* just to have access via this struct */ + char userid[0]; /* just to have access via this struct */ } ; -#define SIZEOF_STRUCT_SOCKS4 8 +#define SIZEOF_STRUCT_SOCKS4 ((size_t)&((struct socks4 *)0)->userid) extern const struct optdesc opt_socksport; extern const struct optdesc opt_socksuser;