plan 9 kernel history: overview | file list | diff list

2001/0331/port/parse.c (diff list | history)

2000/0308/sys/src/9/port/parse.c:11,232001/0331/sys/src/9/port/parse.c:11,30 (short | long | prev | next)
Bug fix: guard against error in user to kernel memmove.
rsc Fri Mar 4 12:44:25 2005
1999/0316    
Cmdbuf* 
parsecmd(char *p, int n) 
{ 
	Cmdbuf *cb; 
2001/0331    
	Cmdbuf *volatile cb; 
1999/0316    
 
	cb = smalloc(sizeof(*cb)); 
	 
	if(n > sizeof(cb->buf)-1) 
		n = sizeof(cb->buf)-1; 
2001/0331    
 
	if(waserror()){ 
		free(cb); 
		nexterror(); 
	} 
1999/0316    
	memmove(cb->buf, p, n); 
2001/0331    
	poperror(); 
 
1999/0316    
	if(n > 0 && cb->buf[n-1] == '\n') 
		n--; 
	cb->buf[n] = '\0'; 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)