summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--package/targets.mak2
-rw-r--r--src/libs6net/s6net_ident_reply_get.c5
-rw-r--r--src/minidentd/mgetuid-linux.c13
4 files changed, 19 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 46f8376..4ec01d3 100644
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,7 @@
it: all
CC = $(error Please use ./configure first)
+EXTRA_TARGETS :=
-include config.mak
include package/targets.mak
@@ -35,7 +36,7 @@ ALL_INCLUDES := $(wildcard src/include/$(package)/*.h)
all: $(ALL_LIBS) $(ALL_BINS) $(ALL_INCLUDES)
clean:
- @exec rm -f $(ALL_LIBS) $(ALL_BINS) $(wildcard src/*/*.o src/*/*.lo)
+ @exec rm -f $(ALL_LIBS) $(ALL_BINS) $(wildcard src/*/*.o src/*/*.lo) $(EXTRA_TARGETS)
distclean: clean
@exec rm -f config.mak src/include/${package}/config.h
diff --git a/package/targets.mak b/package/targets.mak
index 4d1654c..e4d1a70 100644
--- a/package/targets.mak
+++ b/package/targets.mak
@@ -34,6 +34,8 @@ ifdef DO_STATIC
STATIC_LIBS := libs6net.a
endif
+EXTRA_TARGETS := src/minidentd/mgetuid.c
+
src/minidentd/mgetuid.c: src/minidentd/mgetuid-linux.c src/minidentd/mgetuid-default.c
if grep -iF -- -linux- $(sysdeps)/target ; then \
ln -sf mgetuid-linux.c src/minidentd/mgetuid.c ; \
diff --git a/src/libs6net/s6net_ident_reply_get.c b/src/libs6net/s6net_ident_reply_get.c
index 3e11121..b12925f 100644
--- a/src/libs6net/s6net_ident_reply_get.c
+++ b/src/libs6net/s6net_ident_reply_get.c
@@ -19,7 +19,7 @@ int s6net_ident_reply_get (char *s, ip46_t const *remoteip, uint16 remoteport, i
fd = socket_tcp46(ip46_is6(remoteip)) ;
if (fd < 0) return -1 ;
if (socket_bind46(fd, localip, 0) < 0) goto err ;
- if (socket_deadlineconnstamp46(fd, remoteip, 113, deadline, stamp) <= 0) goto err ;
+ if (!socket_deadlineconnstamp46(fd, remoteip, 113, deadline, stamp)) goto err ;
{
char buf[S6NET_IDENT_REPLY_SIZE + 1] ;
char fmt[UINT16_FMT] ;
@@ -35,8 +35,7 @@ int s6net_ident_reply_get (char *s, ip46_t const *remoteip, uint16 remoteport, i
if (sanitize_read(timed_getlnmax(&b, s, S6NET_IDENT_REPLY_SIZE, &len, '\n', deadline, stamp)) <= 0) goto err ;
}
fd_close(fd) ;
- if (len < 2) return (errno = EPROTO, -1) ;
- len -= 2 ;
+ if (!len--) return (errno = EPROTO, -1) ;
s[len] = 0 ;
return (int)len ;
diff --git a/src/minidentd/mgetuid-linux.c b/src/minidentd/mgetuid-linux.c
index 442f642..209318b 100644
--- a/src/minidentd/mgetuid-linux.c
+++ b/src/minidentd/mgetuid-linux.c
@@ -28,6 +28,17 @@ static int skipspace (char **s)
return (int)**s ;
}
+static void reverse_address (char *s, unsigned int n)
+{
+ register unsigned int i = n >> 1 ;
+ while (i--)
+ {
+ register char tmp = s[i] ;
+ s[i] = s[n-1-i] ;
+ s[n-1-i] = tmp ;
+ }
+}
+
static int parseline (char *s, unsigned int len, unsigned int *u, char *la, uint16 *lp, char *ra, uint16 *rp, int is6)
{
char *cur = s ;
@@ -44,6 +55,7 @@ static int parseline (char *s, unsigned int len, unsigned int *u, char *la, uint
if ((cur - s + 1 + iplen) > len) bug("local_address") ;
pos = ucharn_scan(cur, la, iplen) ; /* local_address */
+ reverse_address(la, iplen) ;
if (!pos) bug("local_address") ;
cur += pos ;
if ((*cur++) != ':') bug("local_address:") ;
@@ -55,6 +67,7 @@ static int parseline (char *s, unsigned int len, unsigned int *u, char *la, uint
if ((cur - s + 1 + iplen) > len) bug("remote_address") ;
pos = ucharn_scan(cur, ra, iplen) ; /* remote_address */
+ reverse_address(ra, iplen) ;
if (!pos) bug("remote_address") ;
cur += pos ;
if ((*cur++) != ':') bug("remote_address:") ;