From: nekral-guest Date: Fri, 13 Jun 2008 18:34:27 +0000 (+0000) Subject: * libmisc/rlogin.c: The size argument of read() is a size_t. X-Git-Tag: 4.1.3~393 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=71dda8b648a81c89ccabddb8396c14b8e06b35b3;p=shadow * libmisc/rlogin.c: The size argument of read() is a size_t. Propagate this time to the callers (the get_remote_string() and do_rlogin() functions). * libmisc/rlogin.c: Add brackets and parenthesis. * libmisc/rlogin.c: Avoid multi-statements lines. * libmisc/rlogin.c: Avoid assignments in comparisons. * libmisc/rlogin.c: Avoid implicit conversion of pointers to booleans. --- diff --git a/ChangeLog b/ChangeLog index b6257186..726b56bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-06-13 Nicolas François + + * libmisc/rlogin.c: The size argument of read() is a size_t. + Propagate this time to the callers (the get_remote_string() and + do_rlogin() functions). + * libmisc/rlogin.c: Add brackets and parenthesis. + * libmisc/rlogin.c: Avoid multi-statements lines. + * libmisc/rlogin.c: Avoid assignments in comparisons. + * libmisc/rlogin.c: Avoid implicit conversion of pointers to + booleans. + 2008-06-13 Nicolas François * libmisc/failure.c: Avoid assignments in comparisons. diff --git a/libmisc/rlogin.c b/libmisc/rlogin.c index 0ca1a51b..2217c220 100644 --- a/libmisc/rlogin.c +++ b/libmisc/rlogin.c @@ -110,21 +110,25 @@ static struct { -1, -1} }; -static void get_remote_string (char *buf, int size) +static void get_remote_string (char *buf, size_t size) { for (;;) { - if (read (0, buf, 1) != 1) + if (read (0, buf, 1) != 1) { exit (1); - if (*buf == '\0') + } + if ('\0' == *buf) { return; - if (--size > 0) + } + --size; + if (size > 0) { ++buf; + } } /*NOTREACHED*/} int -do_rlogin (const char *remote_host, char *name, int namelen, char *term, - int termlen) +do_rlogin (const char *remote_host, char *name, size_t namelen, char *term, + size_t termlen) { struct passwd *pwd; char remote_name[32]; @@ -138,19 +142,24 @@ do_rlogin (const char *remote_host, char *name, int namelen, char *term, get_remote_string (name, namelen); get_remote_string (term, termlen); - if ((cp = strchr (term, '/'))) { - *cp++ = '\0'; + cp = strchr (term, '/'); + if (NULL != cp) { + *cp = '\0'; + cp++; remote_speed = atoi (cp); if (0 == remote_speed) { remote_speed = 9600; } } - for (i = 0; speed_table[i].spd_baud != remote_speed && - speed_table[i].spd_name != -1; i++); + for (i = 0; + ( (speed_table[i].spd_baud != remote_speed) + && (speed_table[i].spd_name != -1)); + i++); - if (speed_table[i].spd_name != -1) + if (-1 != speed_table[i].spd_name) { speed_name = speed_table[i].spd_name; + } /* * Put the terminal in cooked mode with echo turned on.