48 Commits

Author SHA1 Message Date
Todd C. Miller
27963e39f3 Pass "make spell" with updated codespell.
Some checks are pending
CodeQL / Analyze (cpp) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
CIFuzz / Fuzzing (push) Waiting to run
2024-04-29 09:19:52 -06:00
THE-Spellchecker
5eba4b48cf Typographical and Grammatical fixes 2023-11-28 15:00:04 -07:00
Todd C. Miller
e343e07543 Use #include <foo.h> instead of #include "foo.h" in most cases.
We rely on the include path to find many of these headers.  It
especially doesn't make sense to use #include "foo.h" for headers
in the top-level include directory.
2023-09-25 10:13:28 -06:00
Todd C. Miller
d53bbb54b2 Add macros to determine the length of an integer type in string form.
Adapted from answer #6 in:
https://stackoverflow.com/questions/10536207/ansi-c-maximum-number-of-characters-printing-a-decimal-int
2023-09-19 15:15:02 -06:00
Rose
5d758264ab Give every printf-like function restrict qualifiers
The format value has to be a string literal, every time.

Otherwise, you are not using these functions correctly. To reinforce this fact, I putrestrict over every non-contrib example of this I could find.
2023-07-07 20:23:20 -04:00
Todd C. Miller
5768d374cc libsudo_util: silence most -Wconversion warnings. 2023-07-07 15:07:04 -06:00
Todd C. Miller
f5eb1e0550 sudo_lbuf_expand: limit allocation to UINT_MAX 2023-07-03 19:46:37 -06:00
Todd C. Miller
56a431f7ea Make sudo_pow2_roundup() operate on size_t. 2023-07-03 16:51:05 -06:00
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
8fbdd414ce Avoid use of variable length arrays and add ctype(3) casts. 2023-06-10 10:48:53 -06:00
Brilliant Hanabi
932339ed9f Add %n$s support for sudo_lbuf_append_v1 2023-06-09 23:20:39 +08:00
Todd C. Miller
0be5a51918 Add missing include of errno.h. 2023-02-23 09:14:28 -07:00
Todd C. Miller
3281d0eec4 sudo_lbuf_expand: check for overflow when rounding to the nearest power of 2.
Problem deteced by oss-fuzz using the fuzz_sudoers fuzzer.
2023-02-23 08:19:18 -07:00
Todd C. Miller
334daf92b3 Escape control characters in log messages and "sudoreplay -l" output.
The log message contains user-controlled strings that could include
things like terminal control characters.  Space characters in the
command path are now also escaped.

Command line arguments that contain spaces are surrounded with
single quotes and any literal single quote or backslash characters
are escaped with a backslash.  This makes it possible to distinguish
multiple command line arguments from a single argument that contains
spaces.

Issue found by Matthieu Barjole and Victor Cutillas of Synacktiv
(https://synacktiv.com).
2023-01-18 08:21:34 -07:00
Todd C. Miller
1b7604e5cb sudo_lbuf_print: no longer need to check for lbuf->len > 0.
Now that lbuf length is unsigned the earlier check for len == 0 is
sufficient.
2023-01-09 14:16:59 -07:00
Todd C. Miller
ca297658dd Increase minimum allocation size from 256 to 1024 bytes. 2023-01-09 14:15:23 -07:00
Todd C. Miller
532023f7b6 sudo_lbuf_expand: don't allocate less than 256 bytes at a time. 2023-01-04 10:36:09 -07:00
Todd C. Miller
dc9ef69021 sudo_lbuf_expand: round nearest power of two instead of multiple of 256. 2023-01-03 21:34:20 -07:00
Todd C. Miller
13df52889f sudo_lbuf_expand: check for possible integer overflow
The numeric fields in struct sudo_lbuf are now unsigned so that
wraparound is defined, this make the overflow checks simpler.
Problem deteced by oss-fuzz using the fuzz_sudoers fuzzer.
2023-01-03 20:02:01 -07:00
Todd C. Miller
13672f28df Make sudo pass -Wwrite-strings 2022-06-28 16:33:15 -06:00
Todd C. Miller
7f27b04616 In sudo_lbuf_destroy(), reset error, len and size. 2021-03-01 16:05:51 -07:00
Todd C. Miller
446ae3f507 Include string.h unconditionally and only use strings.h for strn?casecmp()
In the pre-POSIX days BSD had strings.h, not string.h.
Now strings.h is only used for non-ANSI string functions.
2020-05-18 07:59:24 -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
486ee2b71f debug_decl and debug_decl_vars now require a semicolon at the end. 2019-12-22 08:48:16 -07:00
Todd C. Miller
1e1ef61902 Add SPDX-License-Identifier to files. 2019-04-29 07:21:51 -06:00
Todd C. Miller
6c3d20cb41 Convert PVS-Studio comment to ANSI C. 2018-10-26 08:39:09 -06:00
Todd C. Miller
019279a4b8 Fix some mangled text in the license block. 2018-10-26 08:19:41 -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
670d8e6d77 Special case comment lines in lbufs. 2018-03-04 07:03:41 -07:00
Todd C. Miller
48fba3c2cc update my email to Todd.Miller@sudo.ws 2017-12-03 17:53:40 -07:00
Todd C. Miller
d4211081c0 Add some debugging printfs when malloc fails and we don't have an
explicit call to sudo_warnx().
2015-07-14 15:28:01 -06:00
Todd C. Miller
0b241088b3 There's no need to conditionalize the #include <unistd.h>, we require
a POSIX system.
2015-07-02 09:08:28 -06:00
Todd C. Miller
54f9de6cce Add an error flag to the lbuf struct to simplify error checking.
Callers of the lbuf functions now check the error flag to tell if
a memory allocation error ocurred.
2015-06-26 15:58:04 -06:00
Todd C. Miller
4a07b472f0 Only include stddef.h where it is needed. 2015-06-20 05:34:35 -06:00
Todd C. Miller
dc883f2454 We require ANSI C so stop using the obsolete STDC_HEADERS. 2015-06-19 14:29:27 -06:00
Todd C. Miller
4f9cabd005 Remove obsolete memory.h include. 2015-06-18 21:02:57 -06:00
Todd C. Miller
5ce50a885c Use non-exiting allocators in libsudo_util. 2015-06-17 17:00:53 -06:00
Todd C. Miller
59ab26dbcc Go back to a 2 args debug_decl and just use the "default" instance,
now renamed "active".
2015-02-01 08:24:49 -07:00
Todd C. Miller
866cfc4fc3 Add support for multiple Debug lines per program. Callers may
register arbitrary debug facilities or use built-in defaults.  We
now use separate Debug statements for plugins and programs.
2014-10-22 13:23:05 -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
152178e4be Don't need sudo_fatal.h 2014-08-31 14:20:44 -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
3687b665cb Rename fatal.h -> sudo_fatal.h 2014-07-21 14:40:18 -06:00
Todd C. Miller
36a5767e3e efree -> sudo_efree for consistency 2014-07-10 15:35:04 -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
7bafa63c15 Don't pollute the namespace with lbuf struct and functions 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