Bug 2176 - unchecked returned value from ftruncate
Summary: unchecked returned value from ftruncate
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sftp (show other bugs)
Version: -current
Hardware: All All
: P5 minor
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_6_9
  Show dependency treegraph
 
Reported: 2013-12-01 04:31 AEDT by Loganaden Velvindron
Modified: 2015-08-11 23:05 AEST (History)
2 users (show)

See Also:


Attachments
sftp_unchecked_return (758 bytes, patch)
2013-12-01 04:31 AEDT, Loganaden Velvindron
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Loganaden Velvindron 2013-12-01 04:31:45 AEDT
Created attachment 2378 [details]
sftp_unchecked_return

@@ -1253,7 +1253,9 @@ do_download(struct sftp_conn *conn, char
 			    "server reordered requests", local_path);
 		}
 		debug("truncating at %llu", (unsigned long long)highwater);
-		ftruncate(local_fd, highwater);

ftruncate value isn't checked.
Comment 1 Darren Tucker 2015-04-15 16:23:25 AEST
Comment on attachment 2378 [details]
sftp_unchecked_return

> 		debug("truncating at %llu", (unsigned long long)highwater);
>-		ftruncate(local_fd, highwater);
>+		if (ftruncate(local_fd, highwater) == -1) {
>+			error("Unable to truncate \"%s\"", local_path);
>+		}

Please add strerror(errno) to the error text to provide a hint about what happened.

>-

Please remove the whitespace change.
Comment 2 Damien Miller 2015-05-28 14:51:36 AEST
applied with darren's changes
Comment 3 Damien Miller 2015-08-11 23:05:13 AEST
Set all RESOLVED bugs to CLOSED with release of OpenSSH 7.1