summaryrefslogtreecommitdiffstats
path: root/lib/libc/net/getservent.c
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2010-04-04 07:21:45 +0000
committerume <ume@FreeBSD.org>2010-04-04 07:21:45 +0000
commitad7b5cc594ec25c321fa7e493162a1e3e4985d7b (patch)
tree3f5f22f88614583566752907377f3ea140207cff /lib/libc/net/getservent.c
parent74ecc8e0c65300d46719c196619820b6d0d30e6f (diff)
downloadFreeBSD-src-ad7b5cc594ec25c321fa7e493162a1e3e4985d7b.zip
FreeBSD-src-ad7b5cc594ec25c321fa7e493162a1e3e4985d7b.tar.gz
Treat '+' as special only when in compat mode, and simplify
the logic bit. MFC after: 2 weeks
Diffstat (limited to 'lib/libc/net/getservent.c')
-rw-r--r--lib/libc/net/getservent.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/lib/libc/net/getservent.c b/lib/libc/net/getservent.c
index 105dbfe..bdbe755 100644
--- a/lib/libc/net/getservent.c
+++ b/lib/libc/net/getservent.c
@@ -315,28 +315,8 @@ files_servent(void *retval, void *mdata, va_list ap)
break;
}
- if (*line=='+') {
- if (serv_mdata->compat_mode != 0)
- st->compat_mode_active = 1;
- } else {
- if (bufsize <= linesize + _ALIGNBYTES +
- sizeof(char *)) {
- *errnop = ERANGE;
- rv = NS_RETURN;
- break;
- }
- aliases = (char **)_ALIGN(&buffer[linesize+1]);
- aliases_size = (buffer + bufsize -
- (char *)aliases) / sizeof(char *);
- if (aliases_size < 1) {
- *errnop = ERANGE;
- rv = NS_RETURN;
- break;
- }
-
- memcpy(buffer, line, linesize);
- buffer[linesize] = '\0';
- }
+ if (*line=='+' && serv_mdata->compat_mode != 0)
+ st->compat_mode_active = 1;
}
if (st->compat_mode_active != 0) {
@@ -367,6 +347,23 @@ files_servent(void *retval, void *mdata, va_list ap)
continue;
}
+ if (bufsize <= linesize + _ALIGNBYTES + sizeof(char *)) {
+ *errnop = ERANGE;
+ rv = NS_RETURN;
+ break;
+ }
+ aliases = (char **)_ALIGN(&buffer[linesize + 1]);
+ aliases_size = (buffer + bufsize -
+ (char *)aliases) / sizeof(char *);
+ if (aliases_size < 1) {
+ *errnop = ERANGE;
+ rv = NS_RETURN;
+ break;
+ }
+
+ memcpy(buffer, line, linesize);
+ buffer[linesize] = '\0';
+
rv = servent_unpack(buffer, serv, aliases, aliases_size,
errnop);
if (rv !=0 ) {
OpenPOWER on IntegriCloud