Commit Graph

39 Commits

Author SHA1 Message Date
Rose
e54ba33ea0 Avoid compiler casting warnings by assigning to the same type where possible
This saves instructions that are related to casting as well as compiler warnings.
2023-06-28 17:25:26 -04:00
Todd C. Miller
2e9e1c80f5 Avoid compiling some code paths that are unreachable when fuzzing. 2022-12-29 10:40:48 -07:00
Todd C. Miller
803998d2bd Only add trailing carriage return to messages if output is a raw tty.
If output is being written to a terminal in "raw" mode, we need to
add a carriage return after the newline to avoid "stair-step" output.
However, we should not write the carriage return if the terminal
is in "cooked" mode, output to a pipe, or output redirected to a file.
Bug #1042.
2022-10-20 08:55:26 -06:00
Todd C. Miller
9077daee93 Avoid clobbering errno in warning(). 2021-05-01 11:35:19 -06:00
Todd C. Miller
9547755c3f Fix deregistration of a callback that is not at the head of the list.
The SLIST_FOREACH_PREVPTR macro doesn't work the way I thought it did.
Just store our own prev pointer and use that instead.
2020-12-30 07:09:35 -07:00
Todd C. Miller
d56347b981 Define sudo_warn_setlocale_t and use sudo_conv_t in sudo_fatal.h.
Works around a bug in older versions of the HP ANSI C compiler
and results in more readable code.
2020-09-05 08:21:43 -06:00
Todd C. Miller
cbad17a994 Move inclusion of compat headers up with the system headers.
Now that sudo_dso_public is defined in config.h we don't need sudo_compat.h
before including the compat headers.
2020-08-12 10:07:07 -06:00
Todd C. Miller
8ef5c4cf9d Set DEFAULT_TEXT_DOMAIN in lib/util's Makefile not individual .c files.
We no longer need to include sudo_gettext.h before sudo_compat.h
2020-05-18 11:19:58 -06:00
Todd C. Miller
dd88460800 We no longer need to include headers we don't use for sudo*.h files.
Previously we needed to include headers required by the various
sudo*h files.  Now those files are more self-sufficient and we
should only include headers needed by code in the various .c files.
2020-05-18 06:47:04 -06:00
Todd C. Miller
f6a3dc6d27 Only write a carriage return if output is to a tty. 2019-11-08 19:40:49 -07:00
Todd C. Miller
b4878c95e7 Include a carriage return when printing warning messages.
Otherwise, if the command is running in a pty the output is stair-stepped.
2019-11-08 16:21:00 -07:00
Todd C. Miller
9d8f374397 Add ssizeof macro that returns ssize_t.
We can use this instead of casting the result of size_t to int.
Also change checks for snprintf() returning <=0 to <0.
2019-06-25 09:45:10 -06:00
Todd C. Miller
1e1ef61902 Add SPDX-License-Identifier to files. 2019-04-29 07:21:51 -06:00
Todd C. Miller
cdd5bb32eb Add sudo_gai_fatal, sudo_gai_vfatal, sudo_gai_vwarn, sudo_gai_warn
and gai_log_warning that use gai_strerror() instead of strerror().
2018-11-05 09:08:05 -07:00
Todd C. Miller
6c3d20cb41 Convert PVS-Studio comment to ANSI C. 2018-10-26 08:39:09 -06:00
Todd C. Miller
64e5d34c57 Add comments in .c files so PVS-Studio will check them. 2018-10-21 08:46:05 -06:00
Todd C. Miller
48fba3c2cc update my email to Todd.Miller@sudo.ws 2017-12-03 17:53:40 -07:00
Todd C. Miller
98a15d9879 Add a struct sudo_conv_callback that contains on_suspend and on_resume
function pointer args plus a closure pointer and at it to the
conversation function.
2015-09-07 06:06:08 -06:00
Todd C. Miller
1100d91e8f Fix typo/thinko in static buffer conversion; use vsnprintf() not snprintf() 2015-05-27 16:41:46 -06:00
Todd C. Miller
f18aa478d3 Use a static buffer for sudo_warn/sudo_fatal messages where possible. 2015-05-26 15:24:54 -06:00
Todd C. Miller
05a01d4c5d Avoid using a leading underbar in defines as they are reserved in
ISO C.
2015-05-21 11:13:20 -06:00
Todd C. Miller
80cb630bc0 In sudo_warn_gettext_v1() call dgettext() not gettext() to make
sure the domain is set correctly.  The sudoers plugin uses its own
text domain.
2015-05-12 15:58:05 -06:00
Todd C. Miller
8bc70a635c Instead of trying to make weak functions work on all platforms,
just use a registration function for a plugin-specific setlocale
function.  The sudoers version just wraps sudoers_setlocale().
2015-05-11 14:51:32 -06:00
Todd C. Miller
bd99dcc028 Add sudo_warn_set_conversation() to specify a conversation function
to use for warn/fatal.  If no conversation function is specified,
the standard error will be used.  We now only need sudo_printf()
for things that use the parser.
2014-10-05 16:41:52 -06:00
Todd C. Miller
8bc688188f Move sudo_printf extern to sudo_util.h 2014-08-31 18:46:26 -06:00
Todd C. Miller
a07ce849f7 Some versions of the HP C Compiler don't export functions that take
function pointers as arguments unless a typedef is used.
2014-08-31 18:33:30 -06:00
Todd C. Miller
47835ff289 Rename missing.h -> sudo_compat.h 2014-07-22 14:25:16 -06:00
Todd C. Miller
844a285391 Version the functions in libsudo_util 2014-07-22 11:26:17 -06:00
Todd C. Miller
127ba1354b Rename gettext.h -> sudo_gettext.h 2014-07-21 14:49:43 -06:00
Todd C. Miller
3687b665cb Rename fatal.h -> sudo_fatal.h 2014-07-21 14:40:18 -06:00
Todd C. Miller
b45727cefa Rename queue.h -> sudo_queue.h to avoid collisions with the system
version.
2014-07-21 14:37:27 -06:00
Todd C. Miller
36a5767e3e efree -> sudo_efree for consistency 2014-07-10 15:35:04 -06:00
Todd C. Miller
12c3b456d8 Add sudo_warn_strerror() that wraps strerror() with calls to
setlocale() in sudoers so we always get the error string in the
user's locale.  Also change _warning() to take the error number as
a parameter instead of examining errno.
2014-07-08 09:52:21 -06:00
Todd C. Miller
2d61d38c23 Add sudo_ prefix to alloc.c functions and rename alloc.h -> sudo_alloc.h 2014-06-27 10:48:31 -06:00
Todd C. Miller
c4c253847e Remove extra sudo_ prefix from vfatalxnodebug and vfatalx_nodebug. 2014-06-27 10:39:49 -06:00
Todd C. Miller
aecef4aa1d Rename warning/fatal -> sudo_warn/sudo_fatal to avoid namespace
pollution in libsudo_util.so.
2014-06-27 09:30:52 -06:00
Todd C. Miller
2166a6afe1 Remove use of setjmp/longjmp in the sudoers plugin. We no longer
call fatal() except in the malloc wrappers and due to libsudo_util
there is now a single copy of fatal/fatalx.
2014-06-26 15:51:15 -06:00
Todd C. Miller
088edcb6f5 Add exported libsudo_util functions to util.exp and mark in headers
using __dso_public.
2014-06-26 15:51:15 -06:00
Todd C. Miller
4d37a4a162 Top level directory reorg
Move src/po -> po
Combine common and compat -> lib/util
Move zlib -> lib/zlib
2014-06-26 15:51:02 -06:00