Skip to content

Commit 6a62dfc

Browse files
committed
Merge branch 'w/7.70/bugfix/CLDSRV-620/strip-trailing-checksums' into tmp/octopus/w/8.8/bugfix/CLDSRV-620/strip-trailing-checksums
2 parents 1c6fb9e + ad1348d commit 6a62dfc

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

lib/api/apiUtils/object/prepareStream.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ function prepareStream(stream, streamingV4Params, log, errCb) {
3131
return stream;
3232
}
3333

34-
function stripTrailingChecksumStream(stream, log, errCb) {
35-
// don't do anything if x-amz-trailer has not been set
36-
if (stream.headers['x-amz-trailer'] === undefined ||
37-
stream.headers['x-amz-trailer'] === '') {
34+
function stripTrailingChecksumStream(stream, log) {
35+
// don't do anything if we are not in the correct integrity check mode
36+
if (stream.headers['x-amz-content-sha256'] !==
37+
'STREAMING-UNSIGNED-PAYLOAD-TRAILER') {
3838
return stream;
3939
}
4040

41-
const trailingChecksumTransform = new TrailingChecksumTransform(log, errCb);
41+
const trailingChecksumTransform = new TrailingChecksumTransform(log);
4242
stream.pipe(trailingChecksumTransform);
4343
trailingChecksumTransform.headers = stream.headers;
4444
return trailingChecksumTransform;

lib/auth/streamingV4/trailingChecksumTransform.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ class TrailingChecksumTransform extends Transform {
99
/**
1010
* @constructor
1111
* @param {object} log - logger object
12-
* @param {function} errCb - callback called if an error occurs
1312
*/
14-
constructor(log, errCb) {
13+
constructor(log) {
1514
super({});
1615
this.log = log;
17-
this.errCb = errCb;
1816
this.chunkSizeBuffer = Buffer.alloc(0);
1917
this.bytesToDiscard = 0; // when trailing \r\n are present, we discard them but they can be in different chunks
2018
this.bytesToRead = 0; // when a chunk is advertised, the size is put here and we forward all bytes
@@ -53,7 +51,7 @@ class TrailingChecksumTransform extends Transform {
5351
const lineBreakIndex = chunk.indexOf('\r');
5452
if (lineBreakIndex === -1) {
5553
if (this.chunkSizeBuffer.byteLength + chunk.byteLength > 10) {
56-
this.log.info('chunk size field too big', {
54+
this.log.error('chunk size field too big', {
5755
chunkSizeBuffer: this.chunkSizeBuffer.toString(),
5856
truncatedChunk: chunk.subarray(0, 16).toString(),
5957
});
@@ -71,7 +69,7 @@ class TrailingChecksumTransform extends Transform {
7169

7270
// chunk-size is sent in hex
7371
if (!/^[0-9a-fA-F]+$/.test(this.chunkSizeBuffer.toString())) {
74-
this.log.info('chunk size is not a valid hex number', {
72+
this.log.error('chunk size is not a valid hex number', {
7573
chunkSizeBuffer: this.chunkSizeBuffer.toString(),
7674
});
7775
return callback(errors.InvalidArgument);
@@ -85,7 +83,7 @@ class TrailingChecksumTransform extends Transform {
8583
}
8684
this.chunkSizeBuffer = Buffer.alloc(0);
8785
if (dataSize === 0) {
88-
// TODO: check if the checksum is correct
86+
// TODO: check if the checksum is correct (S3C-9732)
8987
// last chunk, no more data to read, the stream is closed
9088
this.streamClosed = true;
9189
}

0 commit comments

Comments
 (0)