mirror of
				git://git.code.sf.net/p/cdesktopenv/code
				synced 2025-03-09 15:50:02 +00:00 
			
		
		
		
	sh_close(): Set errno to EBADF for invalid file descriptors (#399)
The sh_close() function fails to set errno to EBADF when passed a negative (invalid) file descriptor. This commit fixes the issue by setting errno if the file descriptor is a negative value (backported from ksh93v- 2012-08-24).
This commit is contained in:
		
							parent
							
								
									9403d326f4
								
							
						
					
					
						commit
						feeb62d15f
					
				
					 1 changed files with 3 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -708,7 +708,10 @@ int sh_close(register int fd)
 | 
			
		|||
	register Sfio_t *sp;
 | 
			
		||||
	register int r = 0;
 | 
			
		||||
	if(fd<0)
 | 
			
		||||
	{
 | 
			
		||||
		errno = EBADF;
 | 
			
		||||
		return(-1);
 | 
			
		||||
	}
 | 
			
		||||
	if(fd >= shp->gd->lim.open_max)
 | 
			
		||||
		sh_iovalidfd(shp,fd);
 | 
			
		||||
	if(!(sp=shp->sftable[fd]) || sfclose(sp) < 0)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue