Bugzilla – Attachment 1519 Details for
Bug 1192
warning: comparison between signed and unsigned
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
make amt size_t and add cast to prevent warnings.
openbsd-scp-sign-compare.patch (text/plain), 1.44 KB, created by
Darren Tucker
on 2008-06-14 03:29:06 AEST
(
hide
)
Description:
make amt size_t and add cast to prevent warnings.
Filename:
MIME Type:
Creator:
Darren Tucker
Created:
2008-06-14 03:29:06 AEST
Size:
1.44 KB
patch
obsolete
>On OpenBSD/amd64 (and, infact any LP64 system), compiling with >-Wsign-compare gives: > >cc -Wsign-compare -c /usr/src/usr.bin/ssh/scp.c >scp.c: In function `source': >scp.c:693: warning: comparison between signed and unsigned >scp.c:702: warning: comparison between signed and unsigned > >I think the cast to off_t is safe, because amt is initialized the >buffer size which is 16k or file's block size, whichever is larger. > >OK? > >(it's also bugzilla #1192) > >Index: scp.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/scp.c,v >retrieving revision 1.162 >diff -u -r1.162 scp.c >--- scp.c 1 Jan 2008 09:06:39 -0000 1.162 >+++ scp.c 13 Jun 2008 01:34:45 -0000 >@@ -607,7 +607,8 @@ > struct stat stb; > static BUF buffer; > BUF *bp; >- off_t i, amt, statbytes; >+ off_t i, statbytes; >+ size_t amt; > int fd = -1, haderr, indx; > char *last, *name, buf[2048], encname[MAXPATHLEN]; > int len; >@@ -628,6 +629,10 @@ > syserr: run_err("%s: %s", name, strerror(errno)); > goto next; > } >+ if (stb.st_size < 0) { >+ run_err("%s: %s", name, "Negative file size"); >+ goto next; >+ } > unset_nonblock(fd); > switch (stb.st_mode & S_IFMT) { > case S_IFREG: >@@ -687,7 +692,7 @@ > set_nonblock(remout); > for (haderr = i = 0; i < stb.st_size; i += bp->cnt) { > amt = bp->cnt; >- if (i + amt > stb.st_size) >+ if (i + (off_t)amt > stb.st_size) > amt = stb.st_size - i; > if (!haderr) { > if (atomicio(read, fd, bp->buf, amt) != amt)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1192
:
1142
| 1519