NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/42201: fts(3): broken compatibility



>Number:         42201
>Category:       lib
>Synopsis:       fts(3): broken compatibility
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 19 17:15:00 +0000 2009
>Originator:     NAKAJIMA Yoshihiro
>Release:        NetBSD-current/20091016
>Organization:
>Environment:
System: NetBSD asura 5.99.20 NetBSD 5.99.20 (ASURA) #9: Sat Oct 17 00:52:50 JST 
2009 nakayosh@asura:/usr/src/sys/arch/amd64/compile/ASURA amd64
Architecture: x86_64
Machine: amd64
>Description:

fts(3)'s compatibility is broken.

>How-To-Repeat:

Prepare old ls(1) and new libc.so.

% cd /tmp
% env LD_PRELOAD=/tmp/netbsd-current/lib/libc.so.12.171 netbsd-5.0.1/bin/ls -l
Segmentation fault (core dumped)

>Fix:

Date: Tue Oct 20 00:05:14 JST 2009
diff -u src/lib/libc/compat/gen/compat_fts.c.ORIG 
src/lib/libc/compat/gen/compat_fts.c
--- src/lib/libc/compat/gen/compat_fts.c.ORIG   2009-01-11 11:46:25.000000000 
+0900
+++ src/lib/libc/compat/gen/compat_fts.c        2009-10-19 23:30:18.000000000 
+0900
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_fts.c,v 1.3 2009/01/11 02:46:25 christos Exp $  */
+/*     $NetBSD$        */
 
 /*
  * Written by Jason R. Thorpe <thorpej%NetBSD.org@localhost>, October 21, 1997.
@@ -17,6 +17,10 @@
 #define __fts_stat_t   struct stat12
 #define __fts_nlink_t  u_int16_t
 #define __fts_ino_t    u_int32_t
+#define __fts_length_t unsigned short
+#define __fts_number_t long
+#define __fts_dev_t    uint32_t
+#define __fts_level_t  short
 
 #include <fts.h>
 #include <compat/include/fts.h>
@@ -46,5 +50,7 @@
     " include <fts.h> for correct reference")
 
 #define        __FTS_COMPAT_TAILINGSLASH
+#define __FTS_COMPAT_LENGTH
+#define __FTS_COMPAT_LEVEL
 
 #include "gen/fts.c"
diff -u src/lib/libc/compat/gen/compat___fts13.c.ORIG 
src/lib/libc/compat/gen/compat___fts13.c
--- src/lib/libc/compat/gen/compat___fts13.c.ORIG       2009-01-11 
11:46:24.000000000 +0900
+++ src/lib/libc/compat/gen/compat___fts13.c    2009-10-19 23:30:33.000000000 
+0900
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat___fts13.c,v 1.5 2009/01/11 02:46:24 christos Exp $      
*/
+/*     $NetBSD$        */
 
 #include "namespace.h"
 #include <sys/cdefs.h>
@@ -27,10 +27,11 @@
 #include <compat/sys/stat.h>
 
 #define __fts_stat_t   struct stat13
-#define        __fts_nlink_t   nlink_t
 #define        __fts_ino_t     u_int32_t
 #define        __fts_length_t  u_short
 #define        __fts_number_t  long
+#define __fts_dev_t    uint32_t
+#define __fts_level_t  short
 
 #define stat           __stat13
 #define lstat          __lstat13
@@ -52,5 +53,6 @@
 
 #define        __FTS_COMPAT_TAILINGSLASH
 #define        __FTS_COMPAT_LENGTH
+#define __FTS_COMPAT_LEVEL
 
 #include "gen/fts.c"
diff -u src/lib/libc/compat/gen/compat___fts30.c.ORIG 
src/lib/libc/compat/gen/compat___fts30.c
--- src/lib/libc/compat/gen/compat___fts30.c.ORIG       2006-07-28 
00:46:30.000000000 +0900
+++ src/lib/libc/compat/gen/compat___fts30.c    2009-10-19 23:30:42.000000000 
+0900
@@ -1,9 +1,11 @@
-/*     $NetBSD: compat___fts30.c,v 1.2 2006/07/27 15:46:30 christos Exp $      
*/
+/*     $NetBSD$        */
 
 #include "namespace.h"
 #include <sys/cdefs.h>
 #include <dirent.h>
 
+#define __LIBC12_SOURCE__
+
 __warn_references(__fts_children30,
     "warning: reference to compatibility __fts_children30();"
     " include <fts.h> for correct reference")
@@ -21,9 +23,18 @@
     " include <fts.h> for correct reference")
 
 #include <sys/stat.h>
+#include <compat/sys/time.h>
+#include <compat/sys/stat.h>
 
+#define __fts_stat_t   struct stat30
 #define        __fts_length_t  u_short
 #define        __fts_number_t  long
+#define __fts_dev_t    uint32_t
+#define __fts_level_t  short
+
+#define stat           __stat30
+#define lstat          __lstat30
+#define fstat          __fstat30
 
 #undef fts_children
 #define fts_children __fts_children30
@@ -36,10 +47,10 @@
 #undef fts_set
 #define fts_set __fts_set30
 
-#define __LIBC12_SOURCE__
 #include <fts.h>
 #include <compat/include/fts.h>
 
 #define        __FTS_COMPAT_LENGTH
+#define __FTS_COMPAT_LEVEL
 
 #include "gen/fts.c"
diff -u src/lib/libc/compat/gen/compat___fts31.c.ORIG 
src/lib/libc/compat/gen/compat___fts31.c
--- src/lib/libc/compat/gen/compat___fts31.c.ORIG       2006-07-28 
00:46:30.000000000 +0900
+++ src/lib/libc/compat/gen/compat___fts31.c    2009-10-19 23:30:52.000000000 
+0900
@@ -1,9 +1,11 @@
-/*     $NetBSD: compat___fts31.c,v 1.1 2006/07/27 15:46:30 christos Exp $      
*/
+/*     $NetBSD$        */
 
 #include "namespace.h"
 #include <sys/cdefs.h>
 #include <dirent.h>
 
+#define __LIBC12_SOURCE__
+
 __warn_references(__fts_children31,
     "warning: reference to compatibility __fts_children31();"
     " include <fts.h> for correct reference")
@@ -21,8 +23,17 @@
     " include <fts.h> for correct reference")
 
 #include <sys/stat.h>
+#include <compat/sys/time.h>
+#include <compat/sys/stat.h>
 
+#define __fts_stat_t   struct stat30
 #define        __fts_number_t  long
+#define __fts_dev_t    uint32_t
+#define __fts_level_t  short
+
+#define stat           __stat30
+#define lstat          __lstat30
+#define fstat          __fstat30
 
 #undef fts_children
 #define fts_children __fts_children31
@@ -35,10 +46,9 @@
 #undef fts_set
 #define fts_set __fts_set31
 
-#define __LIBC12_SOURCE__
 #include <fts.h>
 #include <compat/include/fts.h>
 
-#define        __FTS_COMPAT_LENGTH
+#define __FTS_COMPAT_LEVEL
 
 #include "gen/fts.c"
diff -u src/lib/libc/compat/gen/compat___fts32.c.ORIG 
src/lib/libc/compat/gen/compat___fts32.c
--- src/lib/libc/compat/gen/compat___fts32.c.ORIG       2009-01-11 
11:46:25.000000000 +0900
+++ src/lib/libc/compat/gen/compat___fts32.c    2009-10-19 23:31:03.000000000 
+0900
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat___fts32.c,v 1.2 2009/01/11 02:46:25 christos Exp $      
*/
+/*     $NetBSD$        */
 
 #include "namespace.h"
 #include <sys/cdefs.h>
@@ -23,6 +23,8 @@
 
 #define        __fts_stat_t    struct stat30
 #define        __fts_dev_t     uint32_t
+#define __fts_level_t  short
+
 #undef fts_children
 #define fts_children __fts_children32
 #undef fts_close
@@ -42,7 +44,7 @@
 #include <fts.h>
 #include <compat/include/fts.h>
 
-#define        __FTS_COMPAT_LENGTH
+#define __FTS_COMPAT_LEVEL
 
 #define stat           __stat30
 #define lstat          __lstat30



Home | Main Index | Thread Index | Old Index