Skip to content

Commit 12fd4ab

Browse files
committed
loginrec: Make dstsize signed
dstsize was changed from int to size_t a long time ago, differing from OpenSSH. This is not correct, since ((int)len - dstsize) will be calculated with unsigned arithmetic and wrap, so "> 0" passes. That leads to src going backwards into earlier logininfo struct. Reported by @basavaraj-sm05 Basavaraj S Maneppagol This partially reverts the CVS commit. line_full_name() keeps "unsigned int" to avoid a signed comparison warning. Revision 1.7 - (view) (download) (annotate) - [select for diffs] Mon Jun 23 08:15:05 2003 UTC (23 years ago) by matt Branch: MAIN CVS Tags: RELEASE_0_34, RELEASE_0_35, RELEASE_0_36 Changes since 1.6: +4 -4 lines Diff to previous 1.6 tidying, get rid of some signed/unsigned comparisons, other compiler warnings (git conversion e629f43)
1 parent 7f5b313 commit 12fd4ab

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/loginrec.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ login_utmp_only(struct logininfo *li)
372372
/* line_fullname(): add the leading '/dev/' if it doesn't exist make
373373
* sure dst has enough space, if not just copy src (ugh) */
374374
char *
375-
line_fullname(char *dst, const char *src, size_t dstsize)
375+
line_fullname(char *dst, const char *src, unsigned int dstsize)
376376
{
377377
memset(dst, '\0', dstsize);
378378
if ((strncmp(src, "/dev/", 5) == 0) || (dstsize < (strlen(src) + 5))) {
@@ -386,7 +386,7 @@ line_fullname(char *dst, const char *src, size_t dstsize)
386386

387387
/* line_stripname(): strip the leading '/dev' if it exists, return dst */
388388
char *
389-
line_stripname(char *dst, const char *src, size_t dstsize)
389+
line_stripname(char *dst, const char *src, int dstsize)
390390
{
391391
memset(dst, '\0', dstsize);
392392
if (strncmp(src, "/dev/", 5) == 0)
@@ -403,7 +403,7 @@ line_stripname(char *dst, const char *src, size_t dstsize)
403403
* NOTE: use strncpy because we do NOT necessarily want zero
404404
* termination */
405405
char *
406-
line_abbrevname(char *dst, const char *src, size_t dstsize)
406+
line_abbrevname(char *dst, const char *src, int dstsize)
407407
{
408408
size_t len;
409409

src/loginrec.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ void login_write (struct logininfo *li);
174174
int login_log_entry(struct logininfo *li);
175175

176176
/* produce various forms of the line filename */
177-
char *line_fullname(char *dst, const char *src, size_t dstsize);
178-
char *line_stripname(char *dst, const char *src, size_t dstsize);
179-
char *line_abbrevname(char *dst, const char *src, size_t dstsize);
177+
char *line_fullname(char *dst, const char *src, unsigned int dstsize);
178+
char *line_stripname(char *dst, const char *src, int dstsize);
179+
char *line_abbrevname(char *dst, const char *src, int dstsize);
180180

181181
#endif /* DROPBEAR_HAVE_LOGINREC_H_ */

0 commit comments

Comments
 (0)