[Cuis-dev] [DEFECT] Socket>>#sendStreamContents:checkBlock: obviously broken

Gerald Klix cuis.01 at klix.ch
Sat Sep 21 06:07:11 PDT 2024


Hi all, Hi Juan,

Socket>>#sendStreamContents:checkBlock: does not make
sure it really sent all bytes of each chuck it assumes it had sent.

Admittedly I did not not test this, I was just locking at the code:

sendStreamContents: stream checkBlock: checkBlock
	"Send the data in the stream. Close the stream after you are 	done. 
After each block of data evaluate checkBlock and abort if it returns false.
	Usefull for directly sending contents of a file without reading into 
memory first."
	[
	| chunkSize buffer |
	chunkSize := 5000.
	buffer := ByteArray new: chunkSize.
	stream binary.
	[stream atEnd and: [checkBlock value]]
		whileFalse: [
			buffer := stream next: chunkSize into: buffer.
			self sendData: buffer]]
		ensure: [stream close]

It sends #sendData: to itself, which in turn answers the
number of bytes sent, which is not checked at all.

Since this message is not send in any Cuis code or any
other package I cloned form github, I suppose
the easiest way to solve this issue is to just remove the method.

NB: Chances are high that this method had worked at all on
any interface with the exception of the look-back interface,
because it uses a chunkSize (5000) bigger than the default MTU (1500).


Best Regards,

Gerald


More information about the Cuis-dev mailing list