msvc: opendir: allocate enough memory
The defintion of DIR expects the allocating function to extend dd_name by over-allocating. This is not currently done in our implementation of opendir. Fix this. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
							parent
							
								
									599b0bf438
								
							
						
					
					
						commit
						17194c1e96
					
				|  | @ -5,15 +5,14 @@ | ||||||
|  |  | ||||||
| DIR *opendir(const char *name) | DIR *opendir(const char *name) | ||||||
| { | { | ||||||
| 	int len; | 	int len = strlen(name); | ||||||
| 	DIR *p; | 	DIR *p; | ||||||
| 	p = malloc(sizeof(DIR)); | 	p = malloc(sizeof(DIR) + len + 2); | ||||||
| 	if (!p) | 	if (!p) | ||||||
| 		return NULL; | 		return NULL; | ||||||
|  |  | ||||||
| 	memset(p, 0, sizeof(DIR)); | 	memset(p, 0, sizeof(DIR) + len + 2); | ||||||
| 	strncpy(p->dd_name, name, PATH_MAX); | 	strcpy(p->dd_name, name); | ||||||
| 	len = strlen(p->dd_name); |  | ||||||
| 	p->dd_name[len] = '/'; | 	p->dd_name[len] = '/'; | ||||||
| 	p->dd_name[len+1] = '*'; | 	p->dd_name[len+1] = '*'; | ||||||
|  |  | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Erik Faye-Lund
						Erik Faye-Lund