]> git.sven.stormbind.net Git - sven/exfat-utils.git/blobdiff - libexfat/node.c
New upstream version 1.3.0
[sven/exfat-utils.git] / libexfat / node.c
index b544bd966d1cd7ff8f3733b89909e3cc588b0e68..ab1d7d6d04c7d36831c34c20dda7b0c5a4fade6e 100644 (file)
@@ -3,7 +3,7 @@
        exFAT file system implementation library.
 
        Free exFAT implementation.
-       Copyright (C) 2010-2017  Andrew Nayenko
+       Copyright (C) 2010-2018  Andrew Nayenko
 
        This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
@@ -223,7 +223,8 @@ static bool check_node(const struct exfat* ef, struct exfat_node* node,
                exfat_get_name(node, buffer);
                exfat_error("'%s' has invalid checksum (%#hx != %#hx)", buffer,
                                le16_to_cpu(actual_checksum), le16_to_cpu(meta1->checksum));
-               ret = false;
+               if (!EXFAT_REPAIR(invalid_node_checksum, ef, node))
+                       ret = false;
        }
 
        /*
@@ -516,7 +517,8 @@ static int readdir(struct exfat* ef, struct exfat_node* parent,
                                break; /* deleted entry, ignore it */
 
                        exfat_error("unknown entry type %#hhx", entry.type);
-                       return -EIO;
+                       if (!EXFAT_REPAIR(unknown_entry, ef, parent, &entry, *offset))
+                               return -EIO;
                }
                *offset += sizeof(entry);
        }
@@ -855,7 +857,8 @@ static int find_slot(struct exfat* ef, struct exfat_node* dir,
                                        free(dmap);
                                        return -EIO;
                                case -EINVAL:
-                                       /* slot is occupied, continue searching */
+                                       /* slot at (i-n) is occupied, go back and check (i-n+1) */
+                                       i -= contiguous - 1;
                                        contiguous = 0;
                                        break;
                                }