diff --git a/CHANGES b/CHANGES index 573ef1c..e63912b 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,8 @@ corrections: occur under those conditions. Thanks to Toni Mattila for first reporting this problem. + ftruncate64 cut its argument to 32 bits on systems with 32 bit long type + ####################### V 2.0.0-b7: security: diff --git a/compat.h b/compat.h index bbde6fe..15c9452 100644 --- a/compat.h +++ b/compat.h @@ -1,5 +1,5 @@ /* source: compat.h */ -/* Copyright Gerhard Rieger 2001-2008 */ +/* Copyright Gerhard Rieger 2001-2012 */ /* Published under the GNU General Public License V.2, see file COPYING */ #ifndef __compat_h_included @@ -263,7 +263,13 @@ /* might be checked in later versions */ #ifndef F_off -#define F_off "%ld" +# if HAVE_BASIC_OFF_T==3 +# define F_off "%d" +# elif HAVE_BASIC_OFF_T==5 +# define F_off "%ld" +# else +#error "HAVE_BASIC_OFF_T is out of range:" HAVE_BASIC_OFF_T +# endif #endif /* default: long long */ diff --git a/config.h.in b/config.h.in index 5e9f7f2..6b92a90 100644 --- a/config.h.in +++ b/config.h.in @@ -1,5 +1,5 @@ /* source: config.h.in */ -/* Copyright Gerhard Rieger 2001-2008 */ +/* Copyright Gerhard Rieger 2001-2012 */ /* Published under the GNU General Public License V.2, see file COPYING */ #ifndef __config_h_included @@ -448,6 +448,7 @@ #undef HAVE_BASIC_UID_T #undef HAVE_BASIC_GID_T #undef HAVE_BASIC_TIME_T +#undef HAVE_BASIC_OFF_T #undef HAVE_BASIC_OFF64_T #undef HAVE_BASIC_SOCKLEN_T diff --git a/configure.in b/configure.in index c1352fb..527e32c 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ nl source: configure.in -dnl Copyright Gerhard Rieger 2001-2008 +dnl Copyright Gerhard Rieger 2001-2012 dnl Published under the GNU General Public License V.2, see file COPYING dnl Process this file with autoconf to produce a configure script. @@ -1387,6 +1387,9 @@ AC_BASIC_TYPE([#include #include ], socklen_t, HAVE_BASIC_SOCKLEN_T, sc_cv_type_socklent_basic) +AC_BASIC_TYPE([#include +#include ], off_t, HAVE_BASIC_OFF_T, sc_cv_type_off_basic) + AC_BASIC_TYPE([#include #include ], off64_t, HAVE_BASIC_OFF64_T, sc_cv_type_off64_basic) diff --git a/xio.h b/xio.h index 88a1f19..dc54209 100644 --- a/xio.h +++ b/xio.h @@ -1,5 +1,5 @@ /* source: xio.h */ -/* Copyright Gerhard Rieger 2001-2009 */ +/* Copyright Gerhard Rieger 2001-2012 */ /* Published under the GNU General Public License V.2, see file COPYING */ #ifndef __xio_h_included @@ -566,6 +566,14 @@ union integral { /* some aliases */ #define u_off u_long /* please report when this causes problems */ + +#if HAVE_BASIC_OFF_T==3 +# define u_off u_int +#elif HAVE_BASIC_OFF_T==5 +# define u_off u_long +#else +# error "unexpected size of off_t, please report this as bug" +#endif #if defined(HAVE_BASIC_OFF64_T) && HAVE_BASIC_OFF64_T # if HAVE_BASIC_OFF64_T==5 diff --git a/xioopts.c b/xioopts.c index 6bda52a..364629e 100644 --- a/xioopts.c +++ b/xioopts.c @@ -1,5 +1,5 @@ /* source: xioopts.c */ -/* Copyright Gerhard Rieger 2001-2009 */ +/* Copyright Gerhard Rieger 2001-2012 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for address options handling */ @@ -1851,6 +1851,9 @@ int parseopts_table(const char **a, struct opt **opts, Info2("setting option \"%s\" to %d", ent->desc->defname, (*opts)[i].value.u_byte); break; +#if HAVE_BASIC_OFF_T==3 + case TYPE_OFF32: +#endif case TYPE_INT: if (assign) { char *rest; @@ -1913,7 +1916,9 @@ int parseopts_table(const char **a, struct opt **opts, (*opts)[i].value.u_ushort); break; +#if HAVE_BASIC_OFF_T==5 case TYPE_OFF32: +#endif #if HAVE_STAT64 && defined(HAVE_BASIC_OFF64_T) && HAVE_BASIC_OFF64_T==5 case TYPE_OFF64: #endif @@ -1965,6 +1970,7 @@ int parseopts_table(const char **a, struct opt **opts, (*opts)[i].value.u_longlong); break; #endif /* HAVE_TYPE_LONGLONG */ + case TYPE_UIDT: if (!assign) { Error1("option \"%s\": value required", a0); @@ -1984,6 +1990,7 @@ int parseopts_table(const char **a, struct opt **opts, Info2("setting option \"%s\" to %u", ent->desc->defname, (*opts)[i].value.u_uidt); break; + case TYPE_GIDT: if (!assign) { Error1("option \"%s\": value required", a0); continue; } @@ -2002,6 +2009,7 @@ int parseopts_table(const char **a, struct opt **opts, Info2("setting option \"%s\" to %u", ent->desc->defname, (*opts)[i].value.u_gidt); break; + case TYPE_MODET: if (!assign) { Error1("option \"%s\": value required", a0); continue; @@ -2013,6 +2021,7 @@ int parseopts_table(const char **a, struct opt **opts, Info2("setting option \"%s\" to %u", ent->desc->defname, (*opts)[i].value.u_modet); break; + case TYPE_STRING: if (!assign) { Error1("option \"%s\": value required", a0); @@ -2024,6 +2033,7 @@ int parseopts_table(const char **a, struct opt **opts, Info2("setting option \"%s\" to \"%s\"", ent->desc->defname, (*opts)[i].value.u_string); break; + case TYPE_STRING_NULL: if (!assign) { (*opts)[i].value.u_string = NULL; @@ -2034,11 +2044,13 @@ int parseopts_table(const char **a, struct opt **opts, (*opts)[i].value.u_string); } break; + #if LATER case TYPE_INT3: break; #endif + case TYPE_TIMEVAL: if (!assign) { Error1("option \"%s\": value required", a0); @@ -2056,6 +2068,7 @@ int parseopts_table(const char **a, struct opt **opts, (val-(*opts)[i].value.u_timeval.tv_sec) * 1000000; } break; + #if HAVE_STRUCT_TIMESPEC case TYPE_TIMESPEC: if (!assign) { @@ -2075,6 +2088,7 @@ int parseopts_table(const char **a, struct opt **opts, } break; #endif /* HAVE_STRUCT_TIMESPEC */ + #if HAVE_STRUCT_LINGER case TYPE_LINGER: if (!assign) { @@ -2091,6 +2105,7 @@ int parseopts_table(const char **a, struct opt **opts, (*opts)[i].value.u_linger.l_linger); break; #endif /* HAVE_STRUCT_LINGER */ + case TYPE_INT_INT: if (!assign) { Error1("option \"%s\": values required", a0); @@ -2109,6 +2124,7 @@ int parseopts_table(const char **a, struct opt **opts, Info3("setting option \"%s\" to %d:%d", ent->desc->defname, (*opts)[i].value.u_int, (*opts)[i].value2.u_int); break; + case TYPE_INT_BIN: if (!assign) { Error1("option \"%s\": values required", a0); @@ -2136,6 +2152,7 @@ int parseopts_table(const char **a, struct opt **opts, Info2("setting option \"%s\" to %d:..."/*!!!*/, ent->desc->defname, (*opts)[i].value.u_int); break; + case TYPE_INT_STRING: if (!assign) { Error1("option \"%s\": values required", a0); @@ -2156,6 +2173,7 @@ int parseopts_table(const char **a, struct opt **opts, Info3("setting option \"%s\" to %d:\"%s\"", ent->desc->defname, (*opts)[i].value.u_int, (*opts)[i].value2.u_string); break; + case TYPE_INT_INT_INT: if (!assign) { Error1("option \"%s\": values required", a0); @@ -2180,6 +2198,7 @@ int parseopts_table(const char **a, struct opt **opts, Info4("setting option \"%s\" to %d:%d:%d", ent->desc->defname, (*opts)[i].value.u_int, (*opts)[i].value2.u_int, (*opts)[i].value3.u_int); break; + case TYPE_INT_INT_BIN: if (!assign) { Error1("option \"%s\": values required", a0); @@ -2213,6 +2232,7 @@ int parseopts_table(const char **a, struct opt **opts, Info3("setting option \"%s\" to %d:%d:..."/*!!!*/, ent->desc->defname, (*opts)[i].value.u_int, (*opts)[i].value2.u_int); break; + case TYPE_INT_INT_STRING: if (!assign) { Error1("option \"%s\": values required", a0); @@ -2241,6 +2261,7 @@ int parseopts_table(const char **a, struct opt **opts, (*opts)[i].value3.u_string); break; #if defined(HAVE_STRUCT_IP_MREQ) || defined (HAVE_STRUCT_IP_MREQN) + case TYPE_IP_MREQN: { /* we do not resolve the addresses here because we do not yet know @@ -2861,16 +2882,16 @@ int applyopts(int fd, struct opt *opts, enum e_phase phase) { ++opt; continue; } if (opt->desc->func == OFUNC_SEEK32) { - if (Lseek(fd, opt->value.u_long, opt->desc->major) < 0) { - Error4("lseek(%d, %ld, %d): %s", - fd, opt->value.u_long, opt->desc->major, strerror(errno)); + if (Lseek(fd, opt->value.u_off, opt->desc->major) < 0) { + Error4("lseek(%d, "F_off", %d): %s", + fd, opt->value.u_off, opt->desc->major, strerror(errno)); } #if HAVE_LSEEK64 } else if (opt->desc->func == OFUNC_SEEK64) { /*! this depends on off64_t atomic type */ if (Lseek64(fd, opt->value.u_off64, opt->desc->major) < 0) { - Error4("lseek64(%d, %Ld, %d): %s", + Error4("lseek64(%d, "F_off64", %d): %s", fd, opt->value.u_off64, opt->desc->major, strerror(errno)); } #endif /* HAVE_LSEEK64 */ @@ -3213,17 +3234,17 @@ int applyopts(int fd, struct opt *opts, enum e_phase phase) { } break; case OPT_FTRUNCATE32: - if (Ftruncate(fd, opt->value.u_long) < 0) { - Error3("ftruncate(%d, %ld): %s", - fd, opt->value.u_long, strerror(errno)); + if (Ftruncate(fd, opt->value.u_off) < 0) { + Error3("ftruncate(%d, "F_off"): %s", + fd, opt->value.u_off, strerror(errno)); opt->desc = ODESC_ERROR; ++opt; continue; } break; #if HAVE_FTRUNCATE64 case OPT_FTRUNCATE64: - if (Ftruncate64(fd, opt->value.u_long) < 0) { - Error3("ftruncate64(%d, %ld): %s", - fd, opt->value.u_long, strerror(errno)); + if (Ftruncate64(fd, opt->value.u_off64) < 0) { + Error3("ftruncate64(%d, "F_off64"): %s", + fd, opt->value.u_off64, strerror(errno)); opt->desc = ODESC_ERROR; ++opt; continue; } #endif /* HAVE_FTRUNCATE64 */