There's a bug in function sysAvailable() in file
src/win32/java/runtime/io_md.c, in JDK 1.1.6M.
Note in the following listing of function sysAvailable() that no value
is returned if the call to fstat() fails. This causes JCK test
FISAvailableTest2 in JCK-116ea to fail on win32 systems.
int
sysAvailable(int fd, long *pbytes)
{
long cur, end;
struct stat stbuf;
if (fstat(fd, &stbuf) >= 0) {
int mode = stbuf.st_mode;
if (S_ISCHR(mode) || S_ISFIFO(mode)) {
return (fd == 0) ? stdinAvailable(fd, pbytes) :
nonSeekAvailable(fd, pbytes);
}
if ((cur = lseek(fd, 0L, SEEK_CUR)) == -1) {
return FALSE;
} else if ((end = lseek(fd, 0L, SEEK_END)) == -1) {
return FALSE;
} else if (lseek(fd, cur, SEEK_SET) == -1) {
return FALSE;
}
*pbytes = end - cur;
return TRUE;
}
}
src/win32/java/runtime/io_md.c, in JDK 1.1.6M.
Note in the following listing of function sysAvailable() that no value
is returned if the call to fstat() fails. This causes JCK test
FISAvailableTest2 in JCK-116ea to fail on win32 systems.
int
sysAvailable(int fd, long *pbytes)
{
long cur, end;
struct stat stbuf;
if (fstat(fd, &stbuf) >= 0) {
int mode = stbuf.st_mode;
if (S_ISCHR(mode) || S_ISFIFO(mode)) {
return (fd == 0) ? stdinAvailable(fd, pbytes) :
nonSeekAvailable(fd, pbytes);
}
if ((cur = lseek(fd, 0L, SEEK_CUR)) == -1) {
return FALSE;
} else if ((end = lseek(fd, 0L, SEEK_END)) == -1) {
return FALSE;
} else if (lseek(fd, cur, SEEK_SET) == -1) {
return FALSE;
}
*pbytes = end - cur;
return TRUE;
}
}
- duplicates
-
JDK-4110173 (hpi) sysAvailable on Win32 has a code path that returns without a return stmt
- Closed