]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
debuginfod: Handle not being able to fopen interval_path.
authorMark Wielaard <mark@klomp.org>
Tue, 16 Jun 2020 21:53:03 +0000 (23:53 +0200)
committerMark Wielaard <mark@klomp.org>
Wed, 24 Jun 2020 14:37:35 +0000 (16:37 +0200)
Although we check for and/or create the interval_path right before,
there is still a possibility that the fopen call fails. Handle that
as if the file is unreadable.

Signed-off-by: Mark Wielaard <mark@klomp.org>
debuginfod/ChangeLog
debuginfod/debuginfod-client.c

index bc3bce32ffe3f66953169b7f7019ae0a11ce3241..66511a3f1ca3dc047de7e485eb944ac7ec1d3771 100644 (file)
@@ -1,3 +1,8 @@
+2020-06-16  Mark Wielaard  <mark@klomp.org>
+
+       * debuginfod-client.c (debuginfod_clean_cache): Handle failing
+       fopen (interval_path).
+
 2020-03-29  Mark Wielaard  <mark@klomp.org>
 
        * debuginfod-client.c (debuginfod_add_http_header): Check header
index a7dfbfb18332a2d2f600616fdfe2b841a08f7ce9..0cfc6dfc8879cb8da0bcb9f72b04221ad18cf53b 100644 (file)
@@ -244,9 +244,14 @@ debuginfod_clean_cache(debuginfod_client *c,
   /* Check timestamp of interval file to see whether cleaning is necessary.  */
   time_t clean_interval;
   interval_file = fopen(interval_path, "r");
-  if (fscanf(interval_file, "%ld", &clean_interval) != 1)
+  if (interval_file)
+    {
+      if (fscanf(interval_file, "%ld", &clean_interval) != 1)
+        clean_interval = cache_clean_default_interval_s;
+      fclose(interval_file);
+    }
+  else
     clean_interval = cache_clean_default_interval_s;
-  fclose(interval_file);
 
   if (time(NULL) - st.st_mtime < clean_interval)
     /* Interval has not passed, skip cleaning.  */