mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-31 14:25:15 +00:00
Format T_TIMESPEC as "%d.%d" instead of "%.1f"
This fixes the display of the timeout values in the "sudo -V" output on systems without a C99-compliant snprintf(). The snprintf() replacement sudo ships with does not support floating point.
This commit is contained in:
@@ -130,10 +130,12 @@ dump_defaults(void)
|
||||
sudo_printf(SUDO_CONV_INFO_MSG, "\n");
|
||||
break;
|
||||
case T_TIMESPEC: {
|
||||
/* display timespec in minutes as a double */
|
||||
double d = (double)cur->sd_un.tspec.tv_sec +
|
||||
((double)cur->sd_un.tspec.tv_nsec / 1000000000.0);
|
||||
sudo_printf(SUDO_CONV_INFO_MSG, desc, d / 60.0);
|
||||
/* display timespec in minutes and 10ths of a minute */
|
||||
const int min = cur->sd_un.tspec.tv_sec / 60;
|
||||
int decimin =
|
||||
(((cur->sd_un.tspec.tv_sec % 60) * 10) + 30) / 60;
|
||||
decimin += cur->sd_un.tspec.tv_nsec / 100000000;
|
||||
sudo_printf(SUDO_CONV_INFO_MSG, desc, min, decimin);
|
||||
sudo_printf(SUDO_CONV_INFO_MSG, "\n");
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user