Hi All,
running LTP test suite on uClibc-nptl for sh4 I found a bug into pread and pwrite
functions.
When the offset is negative it is not correctly handled due to a missing shift operation,
so it is passed to the syscall as the highest unsigned positive value.
Same bug occurs into trunk.
Attached patch fixes the trunk code (libc/sysdeps/linux/sh/pread_write.c)

Regards,
Carmelo
diff -upr libc/sysdeps/linux/sh/pread_write.c 
libc-st/sysdeps/linux/sh/pread_write.c
--- libc/sysdeps/linux/sh/pread_write.c 2007-04-26 10:03:10.154246000 +0200
+++ libc-st/sysdeps/linux/sh/pread_write.c      2007-04-26 10:04:12.474506000 
+0200
@@ -33,7 +33,7 @@ static inline _syscall6(ssize_t, __sysca
 
 ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
 {
-       
return(__syscall_pread(fd,buf,count,0,__LONG_LONG_PAIR((off_t)0,offset)));
+       return(__syscall_pread(fd,buf,count,0,__LONG_LONG_PAIR(offset >> 
31,offset)));
 }
 weak_alias(__libc_pread,pread)
 
@@ -66,7 +66,7 @@ static inline _syscall6(ssize_t, __sysca
 
 ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
 {
-       
return(__syscall_pwrite(fd,buf,count,0,__LONG_LONG_PAIR((off_t)0,offset)));
+       return(__syscall_pwrite(fd,buf,count,0,__LONG_LONG_PAIR(offset >> 
31,offset)));
 }
 weak_alias(__libc_pwrite,pwrite)
 
_______________________________________________
uClibc mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Reply via email to