mirror of
				https://github.com/simon987/sist2.git
				synced 2025-10-31 16:06:53 +00:00 
			
		
		
		
	Hotfix to patch segmentation fault when specifying a very long script
This commit is contained in:
		
							parent
							
								
									dad14fb66d
								
							
						
					
					
						commit
						61cb845a0e
					
				
							
								
								
									
										19
									
								
								src/cli.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								src/cli.c
									
									
									
									
									
								
							| @ -374,8 +374,16 @@ int index_args_validate(index_args_t *args, int argc, const char **argv) { | ||||
|     LOG_DEBUGF("cli.c", "arg es_index=%s", args->es_index) | ||||
|     LOG_DEBUGF("cli.c", "arg index_path=%s", args->index_path) | ||||
|     LOG_DEBUGF("cli.c", "arg script_path=%s", args->script_path) | ||||
|     LOG_DEBUGF("cli.c", "arg async_script=%s", args->async_script) | ||||
|     LOG_DEBUGF("cli.c", "arg script=%s", args->script) | ||||
| 
 | ||||
|     char log_buf[5000]; | ||||
|     strncpy(log_buf, args->script, sizeof(log_buf)); | ||||
|     *(log_buf + sizeof(log_buf) - 1) = '\0'; | ||||
|     LOG_DEBUGF("cli.c", "arg async_script=%s", log_buf) | ||||
| 
 | ||||
|     strncpy(log_buf, args->script, sizeof(log_buf)); | ||||
|     *(log_buf + sizeof(log_buf) - 1) = '\0'; | ||||
|     LOG_DEBUGF("cli.c", "arg script=%s", log_buf) | ||||
| 
 | ||||
|     LOG_DEBUGF("cli.c", "arg print=%d", args->print) | ||||
|     LOG_DEBUGF("cli.c", "arg es_mappings_path=%s", args->es_mappings_path) | ||||
|     LOG_DEBUGF("cli.c", "arg es_mappings=%s", args->es_mappings) | ||||
| @ -535,6 +543,11 @@ int exec_args_validate(exec_args_t *args, int argc, const char **argv) { | ||||
|     } | ||||
| 
 | ||||
|     LOG_DEBUGF("cli.c", "arg script_path=%s", args->script_path) | ||||
|     LOG_DEBUGF("cli.c", "arg script=%s", args->script) | ||||
| 
 | ||||
|     char log_buf[5000]; | ||||
|     strncpy(log_buf, args->script, sizeof(log_buf)); | ||||
|     *(log_buf + sizeof(log_buf) - 1) = '\0'; | ||||
|     LOG_DEBUGF("cli.c", "arg script=%s", log_buf) | ||||
| 
 | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| @ -48,6 +48,12 @@ void vsist_logf(const char *filepath, int level, char *format, va_list ap) { | ||||
|     size_t maxsize = sizeof(log_str) - log_len; | ||||
|     log_len += vsnprintf(log_str + log_len, maxsize, format, ap); | ||||
| 
 | ||||
|     if (log_len >= maxsize) { | ||||
|         fprintf(stderr, "([%s] FIXME: Log string is too long to display: %dB)\n", | ||||
|                 log_levels[level], log_len); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     if (is_tty) { | ||||
|         log_len += sprintf(log_str + log_len, "\033[0m\n"); | ||||
|     } else { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user