Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!linus!vaxine!wjh12!genrad!decvax!ittvax!dcdwest!sdcsvax!sdcrdcf!hplabs!sri-unix!papa%USC-CSE@USC-ECL.ARPA
From: papa%USC-CSE@USC-ECL.ARPA
Newsgroups: net.micro.pc
Subject: Bug in DOS 2.00 Function Call 4B
Message-ID: <961@sri-arpa.UUCP>
Date: Fri, 15-Jun-84 20:59:04 EDT
Article-I.D.: sri-arpa.961
Posted: Fri Jun 15 20:59:04 1984
Date-Received: Wed, 20-Jun-84 00:43:34 EDT
Lines: 66

From:  Marco Papa 

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 
#include 

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