diff options
Diffstat (limited to 'src/libnsss')
-rw-r--r-- | src/libnsss/nsss_switch_grp_get.c | 8 | ||||
-rw-r--r-- | src/libnsss/nsss_switch_grp_read.c | 3 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/libnsss/nsss_switch_grp_get.c b/src/libnsss/nsss_switch_grp_get.c index 4cfb67e..65da4e3 100644 --- a/src/libnsss/nsss_switch_grp_get.c +++ b/src/libnsss/nsss_switch_grp_get.c @@ -8,10 +8,10 @@ int nsss_switch_grp_get (nsss_switch_t *a, struct group *gr, stralloc *sa, genalloc *ga, tain_t const *deadline, tain_t *stamp) { - char c = NSSS_SWITCH_GRP_GET ; - if (!ipc_timed_send(buffer_fd(&a->b), &c, 1, deadline, stamp)) return 0 ; - if (!buffer_timed_get(&a->b, &c, 1, deadline, stamp)) return 0 ; - if ((unsigned char)c == 255) return 0 ; + unsigned char c = NSSS_SWITCH_GRP_GET ; + if (!ipc_timed_send(buffer_fd(&a->b), (char *)&c, 1, deadline, stamp)) return 0 ; + if (!buffer_timed_get(&a->b, (char *)&c, 1, deadline, stamp)) return 0 ; + if (c == 255) return 0 ; if (c) return (errno = c, 0) ; return nsss_switch_grp_read(&a->b, gr, sa, ga, deadline, stamp) ; } diff --git a/src/libnsss/nsss_switch_grp_read.c b/src/libnsss/nsss_switch_grp_read.c index 6152484..74b981b 100644 --- a/src/libnsss/nsss_switch_grp_read.c +++ b/src/libnsss/nsss_switch_grp_read.c @@ -1,5 +1,6 @@ /* ISC license. */ + #include <stdint.h> #include <string.h> #include <errno.h> @@ -33,7 +34,7 @@ int nsss_switch_grp_read (buffer *b, struct group *gr, stralloc *sa, genalloc *g uint32_unpack_big(buf, &x) ; grtmp.gr_gid = x ; uint32_unpack_big(buf + 4, &total) ; uint32_unpack_big(buf + 8, &n) ; - if (n >= 0x30000000u) return (errno = EPROTO, 0) ; + if (total < 2 || n >= 0x30000000u) return (errno = EPROTO, 0) ; if (!stralloc_readyplus(sa, total)) return 0 ; if (!genalloc_readyplus(char *, ga, n+1)) return 0 ; if (!buffer_timed_get(b, sa->s + sa->len, total, deadline, stamp)) return 0 ; |