This is an obscure error, but one that I have encountered in a real world application. When you use scp to copy a file to a remote FIFO file, the internal function call to ftruncate() has to fail, since a FIFO cannot be truncated to the size of the original file. This results in a reported error at the command line, even though the data actually copies as commanded. Example: ------------------------------------------------------ #scp -B -q afile auser@aserver.com:/tmp/fifofile_input scp: /tmp/fifofile_input: truncate: Invalid argument ---------------------------------------------- This results in the contents of the file 'afile' being copied into the remote fifo, but the error is reported and the exit status is also set to 1. Suggested fix: One must add a file status check that the destination file is not a FIFO file before trying the truncate call (line 994 in unpatched 4.3p2 scp.c).
Created attachment 1189 [details] Add test for FIFO file in scp.c prior to truncate attempt.
Created attachment 1304 [details] Truncate only for regular files that already existed I think this patch is a little better - it will skip the truncate if the file did not already exist or if the target is anything but a regular file.
Damien, Your fix to this problem "if (wrerr == NO && (!exists || S_ISREG(stb.st_mode)) && ftruncate(ofd, size) != 0) {" looks like it will work just fine with a FIFO file target.This logic restricts the ftruncate test much more than my fix. As lonk as thats appropriate for all mode types, I agrre it is the right thing to do. Thanks Tom
Fix applied, this will be in OpenSSH 4.7 - thanks!
Close resolved bugs after release.