diff options
author | Simon Rettberg | 2020-10-08 12:24:06 +0200 |
---|---|---|
committer | Simon Rettberg | 2020-10-08 12:24:06 +0200 |
commit | b79d2f21e8f9c0d31568e82b77004a9bbe3b8be3 (patch) | |
tree | dfe3e688b35372711c0a4637f27d229ad04c05dc /src/userlist.c | |
parent | Tweak session killing, don't try login process right away (diff) | |
download | idle-daemon-b79d2f21e8f9c0d31568e82b77004a9bbe3b8be3.tar.gz idle-daemon-b79d2f21e8f9c0d31568e82b77004a9bbe3b8be3.tar.xz idle-daemon-b79d2f21e8f9c0d31568e82b77004a9bbe3b8be3.zip |
Fix potential strcmp() overflow, better packed struct for pipe
Diffstat (limited to 'src/userlist.c')
-rw-r--r-- | src/userlist.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/userlist.c b/src/userlist.c index 4b03959..1f65eb5 100644 --- a/src/userlist.c +++ b/src/userlist.c @@ -84,8 +84,8 @@ int getUserList( struct user *outbuf, int size ) for ( int j = 0; j < deadzone; ++j ) { if ( outbuf[j].user[0] != '\0' && strcmp( outbuf[j].display, u->ut_host ) == 0 ) { if ( outbuf[j].sessionLeader == u->ut_pid - && strcmp( outbuf[j].user, u->ut_user ) == 0 - && strcmp( outbuf[j].device, u->ut_line ) == 0 ) { + && strncmp( outbuf[j].user, u->ut_user, UT_NAMESIZE ) == 0 + && strncmp( outbuf[j].device, u->ut_line, UT_LINESIZE ) == 0 ) { use = j; break; } @@ -111,8 +111,8 @@ int getUserList( struct user *outbuf, int size ) use = j; } } else if ( outbuf[j].sessionLeader == u->ut_pid - && strcmp( outbuf[j].user, u->ut_user ) == 0 - && strcmp( outbuf[j].device, u->ut_line ) == 0 ) { + && strncmp( outbuf[j].user, u->ut_user, UT_NAMESIZE ) == 0 + && strncmp( outbuf[j].device, u->ut_line, UT_LINESIZE ) == 0 ) { use = j; break; } |