Skip to content

Commit d5905bc

Browse files
check popen() return
1 parent 789af21 commit d5905bc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

html/user/get_output3.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ function get_batch_tar() {
110110
//
111111
$cmd = "cd $dir; tar --totals -cf /dev/null * 2>&1";
112112
$f = popen($cmd, "r");
113+
if (!$f) {
114+
error_page('tar --totals failed');
115+
}
113116
$nbytes = -1;
114117
while (1) {
115118
$out = fgets($f);
@@ -121,16 +124,19 @@ function get_batch_tar() {
121124
}
122125
}
123126
if ($nbytes<0) {
124-
error_page('tar --totals failed');
127+
error_page('tar --totals didn't produce result');
125128
}
126129
pclose($f);
127130

128131
// generate tar file and stream to output
129132
//
130133
$name = "batch_$batch_id.tar";
131134
download_header($name, $nbytes);
132-
$cmd = " cd $dir; tar -cf - *";
135+
$cmd = "cd $dir; tar -cf - *";
133136
$f = popen($cmd, "r");
137+
if (!$f) {
138+
error_page('tar failed');
139+
}
134140
while (1) {
135141
$data = fread($f, 256*1024);
136142
if (!$data) {

0 commit comments

Comments
 (0)