Skip to content

Commit 87022b5

Browse files
authored
Defending pana log writes from cross-stream data. (dart-lang#8069)
1 parent a2b74c7 commit 87022b5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pkg/pub_worker/lib/src/analyze.dart

+9-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'dart:async';
6-
import 'dart:convert' show JsonUtf8Encoder, utf8;
6+
import 'dart:convert' show JsonUtf8Encoder, LineSplitter, Utf8Decoder, utf8;
77
import 'dart:io'
88
show Directory, File, IOException, Platform, Process, ProcessSignal, gzip;
99
import 'dart:isolate' show Isolate;
@@ -152,8 +152,14 @@ Future<void> _analyzePackage(
152152
await pana.stdin.close();
153153

154154
await Future.wait<void>([
155-
pana.stderr.forEach(log.add),
156-
pana.stdout.forEach(log.add),
155+
pana.stderr
156+
.transform(Utf8Decoder(allowMalformed: true))
157+
.transform(LineSplitter())
158+
.forEach(log.writeln),
159+
pana.stdout
160+
.transform(Utf8Decoder(allowMalformed: true))
161+
.transform(LineSplitter())
162+
.forEach(log.writeln),
157163
pana.exitOrTimeout(_panaTimeout, () {
158164
log.writeln('TIMEOUT: pana sending SIGTERM/SIGKILL');
159165
}),

0 commit comments

Comments
 (0)