]> granicus.if.org Git - esp-idf/commitdiff
vfs: check error code returned by FS driver open function
authorIvan Grokhotkov <ivan@espressif.com>
Mon, 7 Nov 2016 06:26:21 +0000 (14:26 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Tue, 8 Nov 2016 12:17:08 +0000 (20:17 +0800)
Fixes https://github.com/espressif/esp-idf/issues/78

components/vfs/vfs.c

index bf26968ff7f72a6ccbfcd73fea1a4ab242618a0f..b60c60a818f9fe7ab85298a3dd9399c76b89e9f9 100644 (file)
@@ -151,6 +151,10 @@ int esp_vfs_open(struct _reent *r, const char * path, int flags, int mode)
     const char* path_within_vfs = translate_path(vfs, path);
     int ret;
     CHECK_AND_CALL(ret, r, vfs, open, path_within_vfs, flags, mode);
+    if (ret < 0) {
+        return ret;
+    }
+    assert(ret >= vfs->vfs.fd_offset);
     return ret - vfs->vfs.fd_offset + (vfs->offset << VFS_INDEX_S);
 }