diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/utmps/utmps-utmpd.c | 8 | ||||
-rw-r--r-- | src/utmps/utmps_getid.c | 6 | ||||
-rw-r--r-- | src/utmps/utmps_getline.c | 6 | ||||
-rw-r--r-- | src/utmps/utmps_utmpx_unpack.c | 3 |
4 files changed, 9 insertions, 14 deletions
diff --git a/src/utmps/utmps-utmpd.c b/src/utmps/utmps-utmpd.c index 101e3ad..e40d244 100644 --- a/src/utmps/utmps-utmpd.c +++ b/src/utmps/utmps-utmpd.c @@ -99,7 +99,7 @@ static int idmatch (unsigned short type, char const *id, struct utmpx const *b) else if (type == INIT_PROCESS || type == LOGIN_PROCESS || type == USER_PROCESS || type == DEAD_PROCESS) { if ((b->ut_type == INIT_PROCESS || b->ut_type == LOGIN_PROCESS || b->ut_type == USER_PROCESS || b->ut_type == DEAD_PROCESS) - && !strncmp(id, b->ut_id, UTMPS_UT_IDSIZE - 1)) return 1 ; + && !strncmp(id, b->ut_id, UTMPS_UT_IDSIZE)) return 1 ; } return 0 ; } @@ -135,7 +135,6 @@ static void do_getid (void) char sbuf[1 + sizeof(struct utmpx)] = "" ; get0(rbuf, USHORT_PACK + UTMPS_UT_IDSIZE) ; ushort_unpack_big(rbuf, &type) ; - rbuf[USHORT_PACK + UTMPS_UT_IDSIZE - 1] = 0 ; maybe_open() ; lockit(0) ; for (;;) @@ -160,7 +159,6 @@ static void do_getline (void) char rbuf[UTMPS_UT_LINESIZE] ; char sbuf[1 + sizeof(struct utmpx)] = "" ; get0(rbuf, UTMPS_UT_LINESIZE) ; - rbuf[UTMPS_UT_LINESIZE - 1] = 0 ; maybe_open() ; lockit(0) ; for (;;) @@ -174,7 +172,7 @@ static void do_getline (void) } utmps_utmpx_unpack(sbuf+1, &b) ; if ((b.ut_type == LOGIN_PROCESS || b.ut_type == USER_PROCESS) - && !strncmp(rbuf, b.ut_line, UTMPS_UT_LINESIZE - 1)) break ; + && !strncmp(rbuf, b.ut_line, UTMPS_UT_LINESIZE)) break ; } unlockit() ; buffer_putnoflush(buffer_1small, sbuf, 1 + sizeof(struct utmpx)) ; @@ -201,7 +199,7 @@ static void do_putline (uid_t uid, gid_t gid) char tmp[sizeof(struct utmpx)] ; if (!read_utmp_entry_unlocked(tmp)) break ; utmps_utmpx_unpack(tmp, &b) ; - if (idmatch(u.ut_type, u.ut_id, &b) && !strncmp(u.ut_line, b.ut_line, UTMPS_UT_LINESIZE - 1)) + if (idmatch(u.ut_type, u.ut_id, &b) && !strncmp(u.ut_line, b.ut_line, UTMPS_UT_LINESIZE)) { if (!onestepback()) { diff --git a/src/utmps/utmps_getid.c b/src/utmps/utmps_getid.c index 622fec8..f347b3e 100644 --- a/src/utmps/utmps_getid.c +++ b/src/utmps/utmps_getid.c @@ -12,11 +12,11 @@ int utmps_getid (utmps *a, unsigned short type, char const *id, struct utmpx *b, tain_t const *deadline, tain_t *stamp) { ssize_t r ; - char sbuf[1 + USHORT_PACK + UTMPS_UT_IDSIZE] = "i" ; + char sbuf[1 + USHORT_PACK + UTMPS_UT_IDSIZE] __attribute__ ((nonstring)) ; char rbuf[1 + sizeof(struct utmpx)] ; + sbuf[0] = 'i' ; ushort_pack_big(sbuf + 1, type) ; - memset(sbuf + 1 + USHORT_PACK, 0, UTMPS_UT_IDSIZE) ; - strncpy(sbuf + 1 + USHORT_PACK, id, UTMPS_UT_IDSIZE - 1) ; + strncpy(sbuf + 1 + USHORT_PACK, id, UTMPS_UT_IDSIZE) ; if (!ipc_timed_send(a->fd, sbuf, sizeof(sbuf), deadline, stamp)) return 0 ; r = ipc_timed_recv(a->fd, rbuf, sizeof(rbuf), 0, deadline, stamp) ; if (r < 0) return 0 ; diff --git a/src/utmps/utmps_getline.c b/src/utmps/utmps_getline.c index 4612082..686782a 100644 --- a/src/utmps/utmps_getline.c +++ b/src/utmps/utmps_getline.c @@ -11,10 +11,10 @@ int utmps_getline (utmps *a, char const *line, struct utmpx *b, tain_t const *deadline, tain_t *stamp) { ssize_t r ; - char sbuf[1 + UTMPS_UT_LINESIZE] = "l" ; + char sbuf[1 + UTMPS_UT_LINESIZE] __attribute__ ((nonstring)) ; char rbuf[1 + sizeof(struct utmpx)] ; - memset(sbuf + 1, 0, UTMPS_UT_LINESIZE) ; - strncpy(sbuf + 1, line, UTMPS_UT_LINESIZE - 1) ; + sbuf[0] = 'l' ; + strncpy(sbuf + 1, line, UTMPS_UT_LINESIZE) ; if (!ipc_timed_send(a->fd, sbuf, sizeof(sbuf), deadline, stamp)) return 0 ; r = ipc_timed_recv(a->fd, rbuf, sizeof(rbuf), 0, deadline, stamp) ; if (r < 0) return 0 ; diff --git a/src/utmps/utmps_utmpx_unpack.c b/src/utmps/utmps_utmpx_unpack.c index 218126b..59959cc 100644 --- a/src/utmps/utmps_utmpx_unpack.c +++ b/src/utmps/utmps_utmpx_unpack.c @@ -6,7 +6,4 @@ void utmps_utmpx_unpack (char const *s, struct utmpx *b) { memcpy(b, s, sizeof(struct utmpx)) ; - b->ut_user[UTMPS_UT_NAMESIZE - 1] = 0 ; - b->ut_line[UTMPS_UT_LINESIZE - 1] = 0 ; - b->ut_host[UTMPS_UT_HOSTSIZE - 1] = 0 ; } |