Browse Source

fixes #292

pull/299/head
Peter Andersson 2 years ago
parent
commit
0e3104cde5
  1. 4
      src/spiffs_hydrogen.c
  2. 18
      src/test/test_bugreports.c
  3. 1
      src/test/test_hydrogen.c

4
src/spiffs_hydrogen.c

@ -479,7 +479,9 @@ s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, s32_t len) {
}
if ((fd->flags & SPIFFS_O_APPEND)) {
fd->fdoffset = fd->size == SPIFFS_UNDEFINED_LEN ? 0 : fd->size;
if (fd->size != SPIFFS_UNDEFINED_LEN && fd->size > fd->fdoffset) {
fd->fdoffset = fd->size;
}
}
offset = fd->fdoffset;

18
src/test/test_bugreports.c

@ -1231,6 +1231,23 @@ TEST(certain_file_size_fail_165) {
} TEST_END
TEST(multiple_unflushed_writes_fdoffset_tell_292)
{
fs_reset_specific(0, 0, 64*1024, 4096, 4096, 256);
spiffs_file fh = SPIFFS_open(FS, "test.txt", SPIFFS_O_CREAT | SPIFFS_O_APPEND | SPIFFS_O_WRONLY, 0);
SPIFFS_write(FS, fh, "abcdefghij", 5);
SPIFFS_write(FS, fh, "abcdefghij", 8);
TEST_CHECK_EQ(13, SPIFFS_tell(FS, fh))
SPIFFS_write(FS, fh, "abcdefghij", 2);
SPIFFS_write(FS, fh, "abcdefghij", 2);
TEST_CHECK_EQ(17, SPIFFS_tell(FS, fh))
SPIFFS_close(FS, fh);
return TEST_RES_OK;
}
TEST_END
SUITE_TESTS(bug_tests)
ADD_TEST(nodemcu_full_fs_1)
ADD_TEST(nodemcu_full_fs_2)
@ -1253,6 +1270,7 @@ SUITE_TESTS(bug_tests)
ADD_TEST(fuzzer_found_4)
ADD_TEST(remove_release_fd_152)
ADD_TEST(certain_file_size_fail_165)
ADD_TEST(multiple_unflushed_writes_fdoffset_tell_292)
ADD_TEST_NON_DEFAULT(fuzzer_found_single_1)
ADD_TEST_NON_DEFAULT(log_afl_test)
ADD_TEST_NON_DEFAULT(afl_test)

1
src/test/test_hydrogen.c

@ -2565,4 +2565,3 @@ SUITE_TESTS(hydrogen_tests)
#endif
SUITE_END(hydrogen_tests)

Loading…
Cancel
Save