]> git.sesse.net Git - plocate/commitdiff
When reading mlocate.db, properly skip the configuration block.
authorSteinar H. Gunderson <steinar+nageru@gunderson.no>
Mon, 9 Nov 2020 23:19:58 +0000 (00:19 +0100)
committerSteinar H. Gunderson <steinar+nageru@gunderson.no>
Mon, 9 Nov 2020 23:19:58 +0000 (00:19 +0100)
This could cause some entries to be skipped until we regained sync,
especially in the root directory.

plocate-build.cpp

index 62be45dab81e70a1fd94ca8fa29bc6163487a766..132a3ff83835fd7c579809becbfff043de6b9998 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <algorithm>
 #include <assert.h>
+#include <arpa/inet.h>
 #include <chrono>
 #include <getopt.h>
 #include <iosfwd>
@@ -420,6 +421,12 @@ void read_mlocate(FILE *fp, DatabaseReceiver *receiver)
 
        // TODO: Care about the base path.
        string path = read_cstr(fp);
+
+       if (fseek(fp, ntohl(hdr.conf_size), SEEK_CUR) != 0) {
+               perror("skip conf block");
+               exit(1);
+       }
+
        while (!feof(fp)) {
                handle_directory(fp, receiver);
        }