mirror of
https://repo.or.cz/socat.git
synced 2025-01-09 22:42:33 +00:00
ftruncate64 cut its argument to 32 bits on systems with 32 bit long type
This commit is contained in:
parent
9b09003643
commit
a8f6d853de
6 changed files with 57 additions and 16 deletions
2
CHANGES
2
CHANGES
|
@ -4,6 +4,8 @@ corrections:
|
||||||
occur under those conditions. Thanks to Toni Mattila for first
|
occur under those conditions. Thanks to Toni Mattila for first
|
||||||
reporting this problem.
|
reporting this problem.
|
||||||
|
|
||||||
|
ftruncate64 cut its argument to 32 bits on systems with 32 bit long type
|
||||||
|
|
||||||
####################### V 2.0.0-b7:
|
####################### V 2.0.0-b7:
|
||||||
|
|
||||||
security:
|
security:
|
||||||
|
|
10
compat.h
10
compat.h
|
@ -1,5 +1,5 @@
|
||||||
/* source: compat.h */
|
/* 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 */
|
/* Published under the GNU General Public License V.2, see file COPYING */
|
||||||
|
|
||||||
#ifndef __compat_h_included
|
#ifndef __compat_h_included
|
||||||
|
@ -263,7 +263,13 @@
|
||||||
|
|
||||||
/* might be checked in later versions */
|
/* might be checked in later versions */
|
||||||
#ifndef F_off
|
#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
|
#endif
|
||||||
|
|
||||||
/* default: long long */
|
/* default: long long */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* source: config.h.in */
|
/* 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 */
|
/* Published under the GNU General Public License V.2, see file COPYING */
|
||||||
|
|
||||||
#ifndef __config_h_included
|
#ifndef __config_h_included
|
||||||
|
@ -448,6 +448,7 @@
|
||||||
#undef HAVE_BASIC_UID_T
|
#undef HAVE_BASIC_UID_T
|
||||||
#undef HAVE_BASIC_GID_T
|
#undef HAVE_BASIC_GID_T
|
||||||
#undef HAVE_BASIC_TIME_T
|
#undef HAVE_BASIC_TIME_T
|
||||||
|
#undef HAVE_BASIC_OFF_T
|
||||||
#undef HAVE_BASIC_OFF64_T
|
#undef HAVE_BASIC_OFF64_T
|
||||||
|
|
||||||
#undef HAVE_BASIC_SOCKLEN_T
|
#undef HAVE_BASIC_SOCKLEN_T
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
nl source: configure.in
|
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 Published under the GNU General Public License V.2, see file COPYING
|
||||||
|
|
||||||
dnl Process this file with autoconf to produce a configure script.
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
|
@ -1387,6 +1387,9 @@ AC_BASIC_TYPE([#include <sys/types.h>
|
||||||
#include <unistd.h>], socklen_t, HAVE_BASIC_SOCKLEN_T,
|
#include <unistd.h>], socklen_t, HAVE_BASIC_SOCKLEN_T,
|
||||||
sc_cv_type_socklent_basic)
|
sc_cv_type_socklent_basic)
|
||||||
|
|
||||||
|
AC_BASIC_TYPE([#include <sys/types.h>
|
||||||
|
#include <unistd.h>], off_t, HAVE_BASIC_OFF_T, sc_cv_type_off_basic)
|
||||||
|
|
||||||
AC_BASIC_TYPE([#include <sys/types.h>
|
AC_BASIC_TYPE([#include <sys/types.h>
|
||||||
#include <unistd.h>], off64_t, HAVE_BASIC_OFF64_T, sc_cv_type_off64_basic)
|
#include <unistd.h>], off64_t, HAVE_BASIC_OFF64_T, sc_cv_type_off64_basic)
|
||||||
|
|
||||||
|
|
10
xio.h
10
xio.h
|
@ -1,5 +1,5 @@
|
||||||
/* source: xio.h */
|
/* 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 */
|
/* Published under the GNU General Public License V.2, see file COPYING */
|
||||||
|
|
||||||
#ifndef __xio_h_included
|
#ifndef __xio_h_included
|
||||||
|
@ -567,6 +567,14 @@ union integral {
|
||||||
/* some aliases */
|
/* some aliases */
|
||||||
#define u_off u_long /* please report when this causes problems */
|
#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 defined(HAVE_BASIC_OFF64_T) && HAVE_BASIC_OFF64_T
|
||||||
# if HAVE_BASIC_OFF64_T==5
|
# if HAVE_BASIC_OFF64_T==5
|
||||||
# define u_off64 u_long
|
# define u_off64 u_long
|
||||||
|
|
43
xioopts.c
43
xioopts.c
|
@ -1,5 +1,5 @@
|
||||||
/* source: xioopts.c */
|
/* 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 */
|
/* Published under the GNU General Public License V.2, see file COPYING */
|
||||||
|
|
||||||
/* this file contains the source for address options handling */
|
/* 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,
|
Info2("setting option \"%s\" to %d", ent->desc->defname,
|
||||||
(*opts)[i].value.u_byte);
|
(*opts)[i].value.u_byte);
|
||||||
break;
|
break;
|
||||||
|
#if HAVE_BASIC_OFF_T==3
|
||||||
|
case TYPE_OFF32:
|
||||||
|
#endif
|
||||||
case TYPE_INT:
|
case TYPE_INT:
|
||||||
if (assign) {
|
if (assign) {
|
||||||
char *rest;
|
char *rest;
|
||||||
|
@ -1913,7 +1916,9 @@ int parseopts_table(const char **a, struct opt **opts,
|
||||||
(*opts)[i].value.u_ushort);
|
(*opts)[i].value.u_ushort);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#if HAVE_BASIC_OFF_T==5
|
||||||
case TYPE_OFF32:
|
case TYPE_OFF32:
|
||||||
|
#endif
|
||||||
#if HAVE_STAT64 && defined(HAVE_BASIC_OFF64_T) && HAVE_BASIC_OFF64_T==5
|
#if HAVE_STAT64 && defined(HAVE_BASIC_OFF64_T) && HAVE_BASIC_OFF64_T==5
|
||||||
case TYPE_OFF64:
|
case TYPE_OFF64:
|
||||||
#endif
|
#endif
|
||||||
|
@ -1965,6 +1970,7 @@ int parseopts_table(const char **a, struct opt **opts,
|
||||||
(*opts)[i].value.u_longlong);
|
(*opts)[i].value.u_longlong);
|
||||||
break;
|
break;
|
||||||
#endif /* HAVE_TYPE_LONGLONG */
|
#endif /* HAVE_TYPE_LONGLONG */
|
||||||
|
|
||||||
case TYPE_UIDT:
|
case TYPE_UIDT:
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
Error1("option \"%s\": value required", a0);
|
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,
|
Info2("setting option \"%s\" to %u", ent->desc->defname,
|
||||||
(*opts)[i].value.u_uidt);
|
(*opts)[i].value.u_uidt);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_GIDT:
|
case TYPE_GIDT:
|
||||||
if (!assign) { Error1("option \"%s\": value required", a0);
|
if (!assign) { Error1("option \"%s\": value required", a0);
|
||||||
continue; }
|
continue; }
|
||||||
|
@ -2002,6 +2009,7 @@ int parseopts_table(const char **a, struct opt **opts,
|
||||||
Info2("setting option \"%s\" to %u", ent->desc->defname,
|
Info2("setting option \"%s\" to %u", ent->desc->defname,
|
||||||
(*opts)[i].value.u_gidt);
|
(*opts)[i].value.u_gidt);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_MODET:
|
case TYPE_MODET:
|
||||||
if (!assign) { Error1("option \"%s\": value required", a0);
|
if (!assign) { Error1("option \"%s\": value required", a0);
|
||||||
continue;
|
continue;
|
||||||
|
@ -2013,6 +2021,7 @@ int parseopts_table(const char **a, struct opt **opts,
|
||||||
Info2("setting option \"%s\" to %u", ent->desc->defname,
|
Info2("setting option \"%s\" to %u", ent->desc->defname,
|
||||||
(*opts)[i].value.u_modet);
|
(*opts)[i].value.u_modet);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_STRING:
|
case TYPE_STRING:
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
Error1("option \"%s\": value required", a0);
|
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,
|
Info2("setting option \"%s\" to \"%s\"", ent->desc->defname,
|
||||||
(*opts)[i].value.u_string);
|
(*opts)[i].value.u_string);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_STRING_NULL:
|
case TYPE_STRING_NULL:
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
(*opts)[i].value.u_string = NULL;
|
(*opts)[i].value.u_string = NULL;
|
||||||
|
@ -2034,11 +2044,13 @@ int parseopts_table(const char **a, struct opt **opts,
|
||||||
(*opts)[i].value.u_string);
|
(*opts)[i].value.u_string);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if LATER
|
#if LATER
|
||||||
case TYPE_INT3:
|
case TYPE_INT3:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case TYPE_TIMEVAL:
|
case TYPE_TIMEVAL:
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
Error1("option \"%s\": value required", a0);
|
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;
|
(val-(*opts)[i].value.u_timeval.tv_sec) * 1000000;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if HAVE_STRUCT_TIMESPEC
|
#if HAVE_STRUCT_TIMESPEC
|
||||||
case TYPE_TIMESPEC:
|
case TYPE_TIMESPEC:
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
|
@ -2075,6 +2088,7 @@ int parseopts_table(const char **a, struct opt **opts,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif /* HAVE_STRUCT_TIMESPEC */
|
#endif /* HAVE_STRUCT_TIMESPEC */
|
||||||
|
|
||||||
#if HAVE_STRUCT_LINGER
|
#if HAVE_STRUCT_LINGER
|
||||||
case TYPE_LINGER:
|
case TYPE_LINGER:
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
|
@ -2091,6 +2105,7 @@ int parseopts_table(const char **a, struct opt **opts,
|
||||||
(*opts)[i].value.u_linger.l_linger);
|
(*opts)[i].value.u_linger.l_linger);
|
||||||
break;
|
break;
|
||||||
#endif /* HAVE_STRUCT_LINGER */
|
#endif /* HAVE_STRUCT_LINGER */
|
||||||
|
|
||||||
case TYPE_INT_INT:
|
case TYPE_INT_INT:
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
Error1("option \"%s\": values required", a0);
|
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,
|
Info3("setting option \"%s\" to %d:%d", ent->desc->defname,
|
||||||
(*opts)[i].value.u_int, (*opts)[i].value2.u_int);
|
(*opts)[i].value.u_int, (*opts)[i].value2.u_int);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INT_BIN:
|
case TYPE_INT_BIN:
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
Error1("option \"%s\": values required", a0);
|
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,
|
Info2("setting option \"%s\" to %d:..."/*!!!*/, ent->desc->defname,
|
||||||
(*opts)[i].value.u_int);
|
(*opts)[i].value.u_int);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INT_STRING:
|
case TYPE_INT_STRING:
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
Error1("option \"%s\": values required", a0);
|
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,
|
Info3("setting option \"%s\" to %d:\"%s\"", ent->desc->defname,
|
||||||
(*opts)[i].value.u_int, (*opts)[i].value2.u_string);
|
(*opts)[i].value.u_int, (*opts)[i].value2.u_string);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INT_INT_INT:
|
case TYPE_INT_INT_INT:
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
Error1("option \"%s\": values required", a0);
|
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,
|
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);
|
(*opts)[i].value.u_int, (*opts)[i].value2.u_int, (*opts)[i].value3.u_int);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INT_INT_BIN:
|
case TYPE_INT_INT_BIN:
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
Error1("option \"%s\": values required", a0);
|
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,
|
Info3("setting option \"%s\" to %d:%d:..."/*!!!*/, ent->desc->defname,
|
||||||
(*opts)[i].value.u_int, (*opts)[i].value2.u_int);
|
(*opts)[i].value.u_int, (*opts)[i].value2.u_int);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INT_INT_STRING:
|
case TYPE_INT_INT_STRING:
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
Error1("option \"%s\": values required", a0);
|
Error1("option \"%s\": values required", a0);
|
||||||
|
@ -2241,6 +2261,7 @@ int parseopts_table(const char **a, struct opt **opts,
|
||||||
(*opts)[i].value3.u_string);
|
(*opts)[i].value3.u_string);
|
||||||
break;
|
break;
|
||||||
#if defined(HAVE_STRUCT_IP_MREQ) || defined (HAVE_STRUCT_IP_MREQN)
|
#if defined(HAVE_STRUCT_IP_MREQ) || defined (HAVE_STRUCT_IP_MREQN)
|
||||||
|
|
||||||
case TYPE_IP_MREQN:
|
case TYPE_IP_MREQN:
|
||||||
{
|
{
|
||||||
/* we do not resolve the addresses here because we do not yet know
|
/* 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; }
|
++opt; continue; }
|
||||||
|
|
||||||
if (opt->desc->func == OFUNC_SEEK32) {
|
if (opt->desc->func == OFUNC_SEEK32) {
|
||||||
if (Lseek(fd, opt->value.u_long, opt->desc->major) < 0) {
|
if (Lseek(fd, opt->value.u_off, opt->desc->major) < 0) {
|
||||||
Error4("lseek(%d, %ld, %d): %s",
|
Error4("lseek(%d, "F_off", %d): %s",
|
||||||
fd, opt->value.u_long, opt->desc->major, strerror(errno));
|
fd, opt->value.u_off, opt->desc->major, strerror(errno));
|
||||||
}
|
}
|
||||||
#if HAVE_LSEEK64
|
#if HAVE_LSEEK64
|
||||||
} else if (opt->desc->func == OFUNC_SEEK64) {
|
} else if (opt->desc->func == OFUNC_SEEK64) {
|
||||||
|
|
||||||
/*! this depends on off64_t atomic type */
|
/*! this depends on off64_t atomic type */
|
||||||
if (Lseek64(fd, opt->value.u_off64, opt->desc->major) < 0) {
|
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));
|
fd, opt->value.u_off64, opt->desc->major, strerror(errno));
|
||||||
}
|
}
|
||||||
#endif /* HAVE_LSEEK64 */
|
#endif /* HAVE_LSEEK64 */
|
||||||
|
@ -3213,17 +3234,17 @@ int applyopts(int fd, struct opt *opts, enum e_phase phase) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPT_FTRUNCATE32:
|
case OPT_FTRUNCATE32:
|
||||||
if (Ftruncate(fd, opt->value.u_long) < 0) {
|
if (Ftruncate(fd, opt->value.u_off) < 0) {
|
||||||
Error3("ftruncate(%d, %ld): %s",
|
Error3("ftruncate(%d, "F_off"): %s",
|
||||||
fd, opt->value.u_long, strerror(errno));
|
fd, opt->value.u_off, strerror(errno));
|
||||||
opt->desc = ODESC_ERROR; ++opt; continue;
|
opt->desc = ODESC_ERROR; ++opt; continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#if HAVE_FTRUNCATE64
|
#if HAVE_FTRUNCATE64
|
||||||
case OPT_FTRUNCATE64:
|
case OPT_FTRUNCATE64:
|
||||||
if (Ftruncate64(fd, opt->value.u_long) < 0) {
|
if (Ftruncate64(fd, opt->value.u_off64) < 0) {
|
||||||
Error3("ftruncate64(%d, %ld): %s",
|
Error3("ftruncate64(%d, "F_off64"): %s",
|
||||||
fd, opt->value.u_long, strerror(errno));
|
fd, opt->value.u_off64, strerror(errno));
|
||||||
opt->desc = ODESC_ERROR; ++opt; continue;
|
opt->desc = ODESC_ERROR; ++opt; continue;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_FTRUNCATE64 */
|
#endif /* HAVE_FTRUNCATE64 */
|
||||||
|
|
Loading…
Reference in a new issue