mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-29 05:17:54 +00:00
Format ttydev as (signed) long long, not unsigned.
Now that we parse ttydev as a long long it makes more sense to format it the same way. This completely avoids the sign extension issue on systems where dev_t is signed.
This commit is contained in:
parent
6b90acbfb7
commit
cc8c43c4d6
@ -1293,9 +1293,6 @@
|
|||||||
/* Define to 1 if you want sudo to set $HOME in shell mode. */
|
/* Define to 1 if you want sudo to set $HOME in shell mode. */
|
||||||
#undef SHELL_SETS_HOME
|
#undef SHELL_SETS_HOME
|
||||||
|
|
||||||
/* The size of 'dev_t', as computed by sizeof. */
|
|
||||||
#undef SIZEOF_DEV_T
|
|
||||||
|
|
||||||
/* The size of 'id_t', as computed by sizeof. */
|
/* The size of 'id_t', as computed by sizeof. */
|
||||||
#undef SIZEOF_ID_T
|
#undef SIZEOF_ID_T
|
||||||
|
|
||||||
|
35
configure
vendored
35
configure
vendored
@ -21003,41 +21003,6 @@ printf "%s\n" "$ac_cv_sizeof_long_long" >&6; }
|
|||||||
printf "%s\n" "#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long" >>confdefs.h
|
printf "%s\n" "#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long" >>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 dev_t" >&5
|
|
||||||
printf %s "checking size of dev_t... " >&6; }
|
|
||||||
if test ${ac_cv_sizeof_dev_t+y}
|
|
||||||
then :
|
|
||||||
printf %s "(cached) " >&6
|
|
||||||
else case e in #(
|
|
||||||
e) if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (dev_t))" "ac_cv_sizeof_dev_t" "$ac_includes_default"
|
|
||||||
then :
|
|
||||||
|
|
||||||
else case e in #(
|
|
||||||
e) if test "$ac_cv_type_dev_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 (dev_t)
|
|
||||||
See 'config.log' for more details" "$LINENO" 5; }
|
|
||||||
else
|
|
||||||
ac_cv_sizeof_dev_t=0
|
|
||||||
fi ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_dev_t" >&5
|
|
||||||
printf "%s\n" "$ac_cv_sizeof_dev_t" >&6; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
printf "%s\n" "#define SIZEOF_DEV_T $ac_cv_sizeof_dev_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]];'.
|
||||||
|
@ -2507,7 +2507,6 @@ SUDO_SOCK_SA_LEN
|
|||||||
SUDO_SOCK_SIN_LEN
|
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([dev_t])
|
|
||||||
AC_CHECK_SIZEOF([id_t])
|
AC_CHECK_SIZEOF([id_t])
|
||||||
AC_CHECK_SIZEOF([time_t])
|
AC_CHECK_SIZEOF([time_t])
|
||||||
AC_CHECK_SIZEOF([uid_t])
|
AC_CHECK_SIZEOF([uid_t])
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-License-Identifier: ISC
|
* SPDX-License-Identifier: ISC
|
||||||
*
|
*
|
||||||
* Copyright (c) 2013-2020, 2022 Todd C. Miller <Todd.Miller@sudo.ws>
|
* Copyright (c) 2013-2020, 2022, 2024 Todd C. Miller <Todd.Miller@sudo.ws>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
@ -88,8 +88,7 @@ main(int argc, char *argv[])
|
|||||||
/* Lookup tty name using kernel info if possible. */
|
/* Lookup tty name using kernel info if possible. */
|
||||||
ttydev = get_process_ttyname(pathbuf, sizeof(pathbuf));
|
ttydev = get_process_ttyname(pathbuf, sizeof(pathbuf));
|
||||||
if (ttydev != (dev_t)-1) {
|
if (ttydev != (dev_t)-1) {
|
||||||
char numbuf[STRLEN_MAX_UNSIGNED(unsigned long long) + 1];
|
char numbuf[STRLEN_MAX_SIGNED(long long) + 1];
|
||||||
unsigned long long ullval;
|
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
dev_t newdev;
|
dev_t newdev;
|
||||||
|
|
||||||
@ -98,20 +97,15 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Check that we can format a dev_t as a string and parse it. */
|
/* Check that we can format a dev_t as a string and parse it. */
|
||||||
ntests++;
|
ntests++;
|
||||||
#if SIZEOF_DEV_T == SIZEOF_LONG
|
(void)snprintf(numbuf, sizeof(numbuf), "%lld", (long long)ttydev);
|
||||||
ullval = (unsigned long)ttydev;
|
|
||||||
#else
|
|
||||||
ullval = (unsigned long long)ttydev;
|
|
||||||
#endif
|
|
||||||
(void)snprintf(numbuf, sizeof(numbuf), "%llu", ullval);
|
|
||||||
newdev = sudo_strtonum(numbuf, LLONG_MIN, LLONG_MAX, &errstr);
|
newdev = sudo_strtonum(numbuf, LLONG_MIN, LLONG_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
printf("%s: FAIL unable to parse device number %s: %s",
|
printf("%s: FAIL unable to parse device number %s: %s",
|
||||||
getprogname(), numbuf, errstr);
|
getprogname(), numbuf, errstr);
|
||||||
errors++;
|
errors++;
|
||||||
} else if (ttydev != newdev) {
|
} else if (ttydev != newdev) {
|
||||||
printf("%s: FAIL device mismatch for %s, %s != %llu",
|
printf("%s: FAIL device mismatch for %s, %s != %lld",
|
||||||
getprogname(), pathbuf, numbuf, ullval);
|
getprogname(), pathbuf, numbuf, (long long)ttydev);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
src/sudo.c
10
src/sudo.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-License-Identifier: ISC
|
* SPDX-License-Identifier: ISC
|
||||||
*
|
*
|
||||||
* Copyright (c) 2009-2023 Todd C. Miller <Todd.Miller@sudo.ws>
|
* Copyright (c) 2009-2024 Todd C. Miller <Todd.Miller@sudo.ws>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
@ -620,13 +620,7 @@ get_user_info(struct user_details *ud)
|
|||||||
|
|
||||||
ttydev = get_process_ttyname(path, sizeof(path));
|
ttydev = get_process_ttyname(path, sizeof(path));
|
||||||
if (ttydev != (dev_t)-1) {
|
if (ttydev != (dev_t)-1) {
|
||||||
int len;
|
if (asprintf(&info[++i], "ttydev=%lld", (long long)ttydev) == -1)
|
||||||
#if SIZEOF_DEV_T == SIZEOF_LONG
|
|
||||||
len = asprintf(&info[++i], "ttydev=%lu", (unsigned long)ttydev);
|
|
||||||
#else
|
|
||||||
len = asprintf(&info[++i], "ttydev=%llu", (unsigned long long)ttydev);
|
|
||||||
#endif
|
|
||||||
if (len == -1)
|
|
||||||
goto oom;
|
goto oom;
|
||||||
info[++i] = sudo_new_key_val("tty", path);
|
info[++i] = sudo_new_key_val("tty", path);
|
||||||
if (info[i] == NULL)
|
if (info[i] == NULL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user