[comp.sys.ibm.pc] Bug in MSC5.0 routine _dos_read

alex@mks.UUCP (Alex White) (02/24/88)

The routine _dos_read takes a far pointer as the buffer address.
This pointer is loaded into DS:DX, and the int call is issued.
The problem is that the number of bytes actually read is stored thru a
pointer in the argument list - but this is done BEFORE the value of DS
is restored.  From the debugger, the code in _dos_read reads:
	...
	int	21
	mov	bx,[bp+0c]	# Fetch address of returned byte count
	mov	[bx], ax	# Store it
	pop	ds		# Restore ds as it was before we loaded the
				# far pointer buffer address
Thus the byte count isn't returned - but perhaps worse is an arbitrary word
in memory [possibly in the data you read in] has been destroyed.