Przeglądaj źródła

Bugfix on invalid dateformat

Segfault was thrown when no files were found with matching date
Yann Weber 7 lat temu
rodzic
commit
710515fdab
1 zmienionych plików z 5 dodań i 12 usunięć
  1. 5
    12
      src/ttail_search_files.c

+ 5
- 12
src/ttail_search_files.c Wyświetl plik

42
 		}
42
 		}
43
 		else if (ret == 1)
43
 		else if (ret == 1)
44
 		{
44
 		{
45
-			if(t->verbose)
46
-			{
47
-				fprintf(stderr, "Warning : unable to find \
48
-a valid date in '%s'\n", t->logfile_name[i]);
49
-			}
45
+			fprintf(stderr, "Warning : unable to find a valid date \
46
+in '%s'\n", t->logfile_name[i]);
50
 			free(ftm[i]);
47
 			free(ftm[i]);
51
 			ftm[i] = NULL;
48
 			ftm[i] = NULL;
52
 			fclose(t->logfile[i]);
49
 			fclose(t->logfile[i]);
231
 
228
 
232
 	*id = *off = 0;
229
 	*id = *off = 0;
233
 	valid = 0;
230
 	valid = 0;
234
-	if(ttail_tm_cmp(&(ftm[0][0]), in) > 0)
235
-	{
236
-		*off = *id = 0;
237
-		return 0;
238
-	}
239
-	while(1)
231
+	while(*id < t->logfile_sz)
240
 	{
232
 	{
241
 		if(!ftm[*id])
233
 		if(!ftm[*id])
242
 		{
234
 		{
327
 	}
319
 	}
328
 	if(!valid)
320
 	if(!valid)
329
 	{
321
 	{
330
-		fprintf(stderr, "No files to scan");
322
+		fprintf(stderr, "No files to scan\n");
323
+		return 0;
331
 	}
324
 	}
332
 	/* the answer is somewhere in *id file */
325
 	/* the answer is somewhere in *id file */
333
 	*off = _ttail_from_search_from_end(t, *id, in);
326
 	*off = _ttail_from_search_from_end(t, *id, in);

Loading…
Anuluj
Zapisz