Skip to content

Commit f37b8aa

Browse files
committed
fix: cast file descriptor to size_t for comparison in fd_prestats functions
NOTE: add here for a quick test
1 parent b5eea46 commit f37b8aa

File tree

1 file changed

+3
-3
lines changed
  • core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src

1 file changed

+3
-3
lines changed

core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ fd_prestats_get_entry(struct fd_prestats *pt, __wasi_fd_t fd,
285285
struct fd_prestat **ret) REQUIRES_SHARED(pt->lock)
286286
{
287287
// Test for file descriptor existence.
288-
if (fd >= pt->size)
288+
if ((size_t)fd >= pt->size)
289289
return __WASI_EBADF;
290290
struct fd_prestat *prestat = &pt->prestats[fd];
291291
if (prestat->dir == NULL)
@@ -301,7 +301,7 @@ static __wasi_errno_t
301301
fd_prestats_remove_entry(struct fd_prestats *pt, __wasi_fd_t fd)
302302
{
303303
// Test for file descriptor existence.
304-
if (fd >= pt->size)
304+
if ((size_t)fd >= pt->size)
305305
return __WASI_EBADF;
306306
struct fd_prestat *prestat = &pt->prestats[fd];
307307

@@ -356,7 +356,7 @@ fd_table_get_entry(struct fd_table *ft, __wasi_fd_t fd,
356356
REQUIRES_SHARED(ft->lock)
357357
{
358358
// Test for file descriptor existence.
359-
if (fd >= ft->size) {
359+
if ((size_t)fd >= ft->size) {
360360
return __WASI_EBADF;
361361
}
362362

0 commit comments

Comments
 (0)