mirror of
				https://codeberg.org/1414codeforge/ubgpsuite.git
				synced 2025-06-05 21:29:11 +02:00 
			
		
		
		
	[tools/peerindex] Prevent possible clobbering of argc,argv after longjmp()
This commit is contained in:
		| @@ -407,20 +407,23 @@ int main(int argc, char **argv) | |||||||
| 	argc -= optind; | 	argc -= optind; | ||||||
| 	argv += optind; | 	argv += optind; | ||||||
|  |  | ||||||
| 	// Move to filtering rules and compile them | 	// Take file list | ||||||
| 	if (argc == 0) { | 	char **files  = argv; | ||||||
|  | 	int    nfiles = argc; | ||||||
|  |  | ||||||
|  | 	if (nfiles == 0) { | ||||||
| 		// If no FILES are provided, read from stdin | 		// If no FILES are provided, read from stdin | ||||||
| 		static const char *const stdinFile[] = { "-" }; | 		static const char *const stdinFile[] = { "-" }; | ||||||
|  |  | ||||||
| 		argv = (char **) stdinFile; | 		files  = (char **) stdinFile; | ||||||
| 		argc = ARRAY_SIZE(stdinFile); | 		nfiles = ARRAY_SIZE(stdinFile); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	volatile int i = 0; | 	volatile int i = 0; | ||||||
|  |  | ||||||
| 	setjmp(S.dropFileFrame);  // NOTE: The ONLY place where this is set | 	setjmp(S.dropFileFrame);  // NOTE: The ONLY place where this is set | ||||||
| 	while (i < argc) | 	while (i < nfiles) | ||||||
| 		Peerindex_ProcessMrtDump(argv[i++]); | 		Peerindex_ProcessMrtDump(files[i++]); | ||||||
|  |  | ||||||
| 	if (S.outfOps->Close) S.outfOps->Close(S.outf); | 	if (S.outfOps->Close) S.outfOps->Close(S.outf); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user