kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'bugfix/return_EINVAL_if_truncate_length_minus_zero' into 'master'
fatfs: return EINVAL if truncate length is less than 0 Closes IDFCI-390 See merge request espressif/esp-idf!11980pull/6416/head
commit
a0eab085ad
|
@ -261,7 +261,7 @@ void test_fatfs_truncate_file(const char* filename)
|
|||
TEST_ASSERT_EQUAL(errno, EPERM);
|
||||
|
||||
TEST_ASSERT_EQUAL(-1, truncate(filename, -1));
|
||||
TEST_ASSERT_EQUAL(errno, EPERM);
|
||||
TEST_ASSERT_EQUAL(errno, EINVAL);
|
||||
|
||||
|
||||
// Truncating should succeed
|
||||
|
@ -294,7 +294,7 @@ void test_fatfs_truncate_file(const char* filename)
|
|||
TEST_ASSERT_EQUAL(EPERM, errno);
|
||||
|
||||
TEST_ASSERT_EQUAL(-1, truncate(filename, -1));
|
||||
TEST_ASSERT_EQUAL(EPERM, errno);
|
||||
TEST_ASSERT_EQUAL(EINVAL, errno);
|
||||
|
||||
|
||||
// Truncating a truncated file should succeed
|
||||
|
|
|
@ -882,12 +882,18 @@ static int vfs_fat_access(void* ctx, const char *path, int amode)
|
|||
static int vfs_fat_truncate(void* ctx, const char *path, off_t length)
|
||||
{
|
||||
FRESULT res;
|
||||
FIL* file;
|
||||
FIL* file = NULL;
|
||||
|
||||
int ret = 0;
|
||||
|
||||
vfs_fat_ctx_t* fat_ctx = (vfs_fat_ctx_t*) ctx;
|
||||
|
||||
if (length < 0) {
|
||||
errno = EINVAL;
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
_lock_acquire(&fat_ctx->lock);
|
||||
prepend_drive_to_path(fat_ctx, &path, NULL);
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue