aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coreutils/dd.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 818ab777e..09e6cccc7 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -22,6 +22,7 @@
22 */ 22 */
23 23
24#include <sys/types.h> 24#include <sys/types.h>
25#include <sys/stat.h>
25#include <stdlib.h> 26#include <stdlib.h>
26#include <stdio.h> 27#include <stdio.h>
27#include <unistd.h> 28#include <unistd.h>
@@ -106,8 +107,13 @@ int dd_main(int argc, char **argv)
106 perror_msg_and_die("%s", outfile); 107 perror_msg_and_die("%s", outfile);
107 108
108 if (seek && trunc) { 109 if (seek && trunc) {
109 if (ftruncate(ofd, seek * bs) < 0) 110 if (ftruncate(ofd, seek * bs) < 0) {
110 perror_msg_and_die("%s", outfile); 111 struct stat st;
112
113 if (fstat (ofd, &st) < 0 || S_ISREG (st.st_mode) ||
114 S_ISDIR (st.st_mode))
115 perror_msg_and_die("%s", outfile);
116 }
111 } 117 }
112 } else { 118 } else {
113 ofd = STDOUT_FILENO; 119 ofd = STDOUT_FILENO;