2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-29 13:28:10 +00:00

Add an OFF_T_MAX define

This will be used for integer overflow checks when copying files.
This commit is contained in:
Todd C. Miller 2025-01-14 11:38:07 -07:00
parent 30729312c2
commit 7c075c100d
4 changed files with 48 additions and 1 deletions

View File

@ -1302,6 +1302,9 @@
/* The size of 'long long', as computed by sizeof. */ /* The size of 'long long', as computed by sizeof. */
#undef SIZEOF_LONG_LONG #undef SIZEOF_LONG_LONG
/* The size of 'off_t', as computed by sizeof. */
#undef SIZEOF_OFF_T
/* The size of 'time_t', as computed by sizeof. */ /* The size of 'time_t', as computed by sizeof. */
#undef SIZEOF_TIME_T #undef SIZEOF_TIME_T

35
configure vendored
View File

@ -21185,6 +21185,41 @@ printf "%s\n" "$ac_cv_sizeof_id_t" >&6; }
printf "%s\n" "#define SIZEOF_ID_T $ac_cv_sizeof_id_t" >>confdefs.h printf "%s\n" "#define SIZEOF_ID_T $ac_cv_sizeof_id_t" >>confdefs.h
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like 'int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of off_t" >&5
printf %s "checking size of off_t... " >&6; }
if test ${ac_cv_sizeof_off_t+y}
then :
printf %s "(cached) " >&6
else case e in #(
e) if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (off_t))" "ac_cv_sizeof_off_t" "$ac_includes_default"
then :
else case e in #(
e) if test "$ac_cv_type_off_t" = yes; then
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5
printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (off_t)
See 'config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_off_t=0
fi ;;
esac
fi
;;
esac
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_off_t" >&5
printf "%s\n" "$ac_cv_sizeof_off_t" >&6; }
printf "%s\n" "#define SIZEOF_OFF_T $ac_cv_sizeof_off_t" >>confdefs.h
# The cast to long int works around a bug in the HP C Compiler # The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like 'int a3[[(sizeof (unsigned char)) >= 0]];'. # declarations like 'int a3[[(sizeof (unsigned char)) >= 0]];'.

View File

@ -3,7 +3,7 @@ dnl Use the top-level autogen.sh script to generate configure and config.h.in
dnl dnl
dnl SPDX-License-Identifier: ISC dnl SPDX-License-Identifier: ISC
dnl dnl
dnl Copyright (c) 1994-1996, 1998-2024 Todd C. Miller <Todd.Miller@sudo.ws> dnl Copyright (c) 1994-1996, 1998-2025 Todd C. Miller <Todd.Miller@sudo.ws>
dnl dnl
dnl Permission to use, copy, modify, and distribute this software for any dnl Permission to use, copy, modify, and distribute this software for any
dnl purpose with or without fee is hereby granted, provided that the above dnl purpose with or without fee is hereby granted, provided that the above
@ -2519,6 +2519,7 @@ SUDO_SOCK_SIN_LEN
AC_CHECK_SIZEOF([long]) AC_CHECK_SIZEOF([long])
AC_CHECK_SIZEOF([long long]) AC_CHECK_SIZEOF([long long])
AC_CHECK_SIZEOF([id_t]) AC_CHECK_SIZEOF([id_t])
AC_CHECK_SIZEOF([off_t])
AC_CHECK_SIZEOF([time_t]) AC_CHECK_SIZEOF([time_t])
AC_CHECK_SIZEOF([uid_t]) AC_CHECK_SIZEOF([uid_t])
# sudo current assumes uid_t can be cast to unsigned int without problems # sudo current assumes uid_t can be cast to unsigned int without problems

View File

@ -33,6 +33,14 @@
#endif #endif
#define ROOT_GID 0 #define ROOT_GID 0
#ifndef OFF_T_MAX
# if SIZEOF_OFF_T == 8
# define OFF_T_MAX LLONG_MAX
# else
# define OFF_T_MAX INT_MAX
# endif
#endif
#ifndef TIME_T_MIN #ifndef TIME_T_MIN
# if SIZEOF_TIME_T == 8 # if SIZEOF_TIME_T == 8
# define TIME_T_MIN LLONG_MIN # define TIME_T_MIN LLONG_MIN