feat(server.c): add newline to pastes
This commit is contained in:
		
							parent
							
								
									6920f38942
								
							
						
					
					
						commit
						5d1cbba1c0
					
				
					 1 changed files with 6 additions and 4 deletions
				
			
		
							
								
								
									
										10
									
								
								server.c
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								server.c
									
										
									
									
									
								
							|  | @ -183,7 +183,7 @@ char *read_paste(int connection) | ||||||
| 
 | 
 | ||||||
|     /* allocate buffer to store the data */ |     /* allocate buffer to store the data */ | ||||||
|     char *buffer; |     char *buffer; | ||||||
|     if ((buffer = malloc((buffer_size + 1) * sizeof(char))) == NULL) |     if ((buffer = malloc((buffer_size + 2) * sizeof(char))) == NULL) | ||||||
|         return NULL; |         return NULL; | ||||||
| 
 | 
 | ||||||
|     /* read all data until EOF is received, or max file size is reached, or the socket timeouts... */ |     /* read all data until EOF is received, or max file size is reached, or the socket timeouts... */ | ||||||
|  | @ -208,7 +208,7 @@ char *read_paste(int connection) | ||||||
| 
 | 
 | ||||||
|             /* reallocate the buffer with a larger size */ |             /* reallocate the buffer with a larger size */ | ||||||
|             void *tmp; |             void *tmp; | ||||||
|             if ((tmp = realloc(buffer, (buffer_size + 1) * sizeof(char))) == NULL) { |             if ((tmp = realloc(buffer, (buffer_size + 2) * sizeof(char))) == NULL) { | ||||||
|                 free(buffer); |                 free(buffer); | ||||||
|                 return NULL; |                 return NULL; | ||||||
|             } |             } | ||||||
|  | @ -227,8 +227,10 @@ char *read_paste(int connection) | ||||||
|         return NULL; |         return NULL; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /* end the buffer with a null byte */ |     /* end the buffer with a newline and a null byte */ | ||||||
|     buffer[total_size] = 0; |     buffer[total_size]     = '\n'; | ||||||
|  |     buffer[total_size + 1] = 0; | ||||||
|  | 
 | ||||||
|     return buffer; |     return buffer; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Tom MTT
						Tom MTT