mirror of
				https://github.com/bytecodealliance/wasm-micro-runtime.git
				synced 2025-10-31 13:17:31 +00:00 
			
		
		
		
	posix_file.c: Correct the dirfd argument that passes to fstatat (#3244)
This PR fixes the random failing test case `nofollow_errors` mentioned in https://github.com/bytecodealliance/wasm-micro-runtime/issues/3222 ```C // dirfd: This is the file descriptor of the directory relative to which the pathname is interpreted. int openat(int dirfd, const char *pathname, int flags, ...); ``` The value should be a directory handle instead of a file handle (which is always -1 in this context) returned from `openat`.
This commit is contained in:
		
							parent
							
								
									b4941b0cde
								
							
						
					
					
						commit
						64b6c688a2
					
				|  | @ -384,7 +384,7 @@ os_openat(os_file_handle handle, const char *path, __wasi_oflags_t oflags, | |||
|         // Linux returns ENXIO instead of EOPNOTSUPP when opening a socket.
 | ||||
|         if (openat_errno == ENXIO) { | ||||
|             struct stat sb; | ||||
|             int ret = fstatat(fd, path, &sb, | ||||
|             int ret = fstatat(handle, path, &sb, | ||||
|                               (lookup_flags & __WASI_LOOKUP_SYMLINK_FOLLOW) | ||||
|                                   ? 0 | ||||
|                                   : AT_SYMLINK_NOFOLLOW); | ||||
|  | @ -396,7 +396,7 @@ os_openat(os_file_handle handle, const char *path, __wasi_oflags_t oflags, | |||
|         if (openat_errno == ENOTDIR | ||||
|             && (open_flags & (O_NOFOLLOW | O_DIRECTORY)) != 0) { | ||||
|             struct stat sb; | ||||
|             int ret = fstatat(fd, path, &sb, AT_SYMLINK_NOFOLLOW); | ||||
|             int ret = fstatat(handle, path, &sb, AT_SYMLINK_NOFOLLOW); | ||||
|             if (S_ISLNK(sb.st_mode)) { | ||||
|                 return __WASI_ELOOP; | ||||
|             } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 TianlongLiang
						TianlongLiang