Check lengths before adding C style strings together. Fixes #498
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4202
This commit is contained in:
		
							parent
							
								
									3978e05909
								
							
						
					
					
						commit
						111fa1d45b
					
				
					 1 changed files with 8 additions and 4 deletions
				
			
		|  | @ -253,17 +253,21 @@ void DOS_Shell::InputCommand(char * line) { | |||
| 					if ((path = strrchr(line+completion_index,'/'))) completion_index = (Bit16u)(path-line+1); | ||||
| 
 | ||||
| 					// build the completion list
 | ||||
| 					char mask[DOS_PATHLENGTH]; | ||||
| 					char mask[DOS_PATHLENGTH] = {0}; | ||||
| 					if (strlen(p_completion_start) + 3 >= DOS_PATHLENGTH) { | ||||
| 						//Beep;
 | ||||
| 						break; | ||||
| 					} | ||||
| 					if (p_completion_start) { | ||||
| 						strcpy(mask, p_completion_start); | ||||
| 						safe_strncpy(mask, p_completion_start,DOS_PATHLENGTH); | ||||
| 						char* dot_pos=strrchr(mask,'.'); | ||||
| 						char* bs_pos=strrchr(mask,'\\'); | ||||
| 						char* fs_pos=strrchr(mask,'/'); | ||||
| 						char* cl_pos=strrchr(mask,':'); | ||||
| 						// not perfect when line already contains wildcards, but works
 | ||||
| 						if ((dot_pos-bs_pos>0) && (dot_pos-fs_pos>0) && (dot_pos-cl_pos>0)) | ||||
| 							strcat(mask, "*"); | ||||
| 						else strcat(mask, "*.*"); | ||||
| 							strncat(mask, "*",DOS_PATHLENGTH - 1); | ||||
| 						else strncat(mask, "*.*",DOS_PATHLENGTH - 1); | ||||
| 					} else { | ||||
| 						strcpy(mask, "*.*"); | ||||
| 					} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue