[net.micro.pc] Bug in DOS 2.00 Function Call 4B

papa%USC-CSE@USC-ECL.ARPA (06/16/84)

From:  Marco Papa <papa%USC-CSE@USC-ECL.ARPA>

While using the exec() routines which are included in the INFO-IBMPC
library (EXEC2.ASM and EXEC3.ASM) I run into an unexpected problem.
DOS Function 4B clobbers some data into the caller's user area.

For example, try to link the following Lattice "C" program with EXEC3.ASM:

#include <stdio.h>
#include <conio.h>

main(argc,argv)
int argc;
char *argv[];
{
	int i;
	char *p;
	char *malloc();

	p = malloc ((unsigned) 256);
	strcpy(p, argv[1]);
	printf("Now executing a command\n\r");
	i = exec(p);
	switch (i) {
	case 0:
		printf("return successful\n\r");
		break;
	case -1:
		printf("Insufficient memory\n\r");
		break;
	case -2:
		printf("access denied\n\r");
		break;
	case -3:
		printf("No such command\n\r");
		break;
	case -4:
		printf("Invalid command format\n\r");
		break;
	case -5:
		printf("Memory control blocks destroyed\n\r");
		break;
	case -6:
		printf("Invalid memory block address\n\r");
		break;
	default:
		printf("You should never get here!\n\r");
		break;
	}	
}

Then, run it as follows:

A>newexec dir

As a result, the DOS DIR command will be properly executed, but the
subsequent printf will show that the data area has been overwritten by
function 4B.

I tested the same program (and other programs that use function 4B, and that
have their data overwritten) under DOS 2.1 and they work perfectly.

The bottom line is: if you use DOS function 4B under DOS 2.0, you do it at
your own risk. Did Microsoft report this DOS 2.1 bug fix to anyone on the net?

Marco Papa