tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
nvi db glue missing prototypes
Three of the functions defined in dist/nvi/common/db1.c are missing
prototypes in db.h. In particular, on amd64, treating the char*
return of db_strerror as implicitly int causes the pointer to be
truncated to 32 bits when passed to snprintf, causing vi to segfault
when accidentally run on a file without read permission.
I've attached a patch that provides prototypes for those functions
and fixes the crash I encountered. I'm not entirely sure how/if the
#ifdef USE_DYNAMIC_LOADING case is supposed to work, so I kept all that
together and moved it to the bottom of db.h, where the types involved
all have the correct definitions.
Comments? Can this be committed?
--
(let ((C call-with-current-continuation)) (apply (lambda (x y) (x y)) (map
((lambda (r) ((C C) (lambda (s) (r (lambda l (apply (s s) l)))))) (lambda
(f) (lambda (l) (if (null? l) C (lambda (k) (display (car l)) ((f (cdr l))
(C k))))))) '((#\J #\d #\D #\v #\s) (#\e #\space #\a #\i #\newline)))))
Index: dist/nvi/common/db.h
===================================================================
RCS file: /bag/nb/repo/src/dist/nvi/common/db.h,v
retrieving revision 1.3
diff -u -p -r1.3 db.h
--- dist/nvi/common/db.h 5 Aug 2008 15:49:18 -0000 1.3
+++ dist/nvi/common/db.h 14 Mar 2009 21:01:04 -0000
@@ -26,16 +26,6 @@
(db)->open(db, file, NULL, type, flags, mode)
#endif
-#ifdef USE_DYNAMIC_LOADING
-#define db_create nvi_db_create
-#define db_env_create nvi_db_env_create
-#define db_strerror nvi_db_strerror
-
-extern int (*nvi_db_create) __P((DB **, DB_ENV *, u_int32_t));
-extern int (*nvi_db_env_create) __P((DB_ENV **, u_int32_t));
-extern char *(*nvi_db_strerror) __P((int));
-#endif
-
#ifdef USE_DB1
#define DB_AFTER 1
@@ -143,4 +133,19 @@ struct __dbc_new {
int (*c_put)(DBC *, DBT *, DBT *, u_int32_t);
};
+
+#ifdef USE_DYNAMIC_LOADING
+#define db_create nvi_db_create
+#define db_env_create nvi_db_env_create
+#define db_strerror nvi_db_strerror
+
+extern int (*nvi_db_create) __P((DB **, DB_ENV *, u_int32_t));
+extern int (*nvi_db_env_create) __P((DB_ENV **, u_int32_t));
+extern char *(*nvi_db_strerror) __P((int));
+#else
+int db_create __P((DB **, DB_ENV *, u_int32_t));
+int db_env_create __P((DB_ENV **, u_int32_t));
+char *db_strerror __P((int));
+#endif
+
#endif /* USE_DB1 */
Home |
Main Index |
Thread Index |
Old Index