Todd C. Miller
2d1b3c369f
Change sudo_strtomode() to return mode_t.
2023-07-05 09:54:22 -06:00
Todd C. Miller
1f0f6b7c78
Fix some indentation.
2023-07-04 18:03:47 -06:00
Todd C. Miller
bfb6132d9c
Add configure tests for __builtin_clz/__builtin_clzl
2023-07-04 12:39:31 -06:00
Todd C. Miller
0f69939d71
Add fallback for compilers without __builtin_clz/__builtin_clzl
2023-07-04 12:29:52 -06:00
Todd C. Miller
3a7ca0a834
sudo_pow2_roundup: fix 64-bit version when shifting 31 or more places
...
Shift 1UL instead of 1 to avoid overflowing an int.
2023-07-04 08:21:21 -06:00
Rose
8c3e4a33cd
Optimize sudo_pow2_roundup_v1
...
No need to call sudo_pow2_roundup_v2.
2023-07-03 22:32:02 -04:00
Todd C. Miller
fa69ee5e1b
Merge pull request #285 from AtariDreams/bug
...
Remove comment about algorithm being from bit-twiddling hacks
2023-07-03 20:26:20 -06:00
Rose
76d7aefb33
Remove comment about algorithm being from bit-twiddling hacks
...
Said comment no longer applies.
2023-07-03 22:24:55 -04:00
Rose
732110428e
Fix fuzzing errors
...
We should be checking for integer overflow, rather than checking if size is 0.
Additionally, we should set errno to ENOMEM when this overflow happens.
Finally, the most efficient implementation of the round-up-to-2 algorithm involves the clz intrinsic.
2023-07-03 22:20:05 -04:00
Todd C. Miller
f5eb1e0550
sudo_lbuf_expand: limit allocation to UINT_MAX
2023-07-03 19:46:37 -06:00
Todd C. Miller
d3dc70ab62
sudo_parseln: use sudo_pow2_roundup() instead of hand-rolling it.
2023-07-03 17:17:47 -06:00
Todd C. Miller
56a431f7ea
Make sudo_pow2_roundup() operate on size_t.
2023-07-03 16:51:05 -06:00
Todd C. Miller
b926df1df2
Make the debug subsystem unsigned.
...
It was already unsigned in sudoers but not in the front-end or the
python plugin. Making this consistent resolves a lot of -Wconversion
warnings. Also clean up some other -Wconversion warnings in sudo_debug.c.
2023-07-01 16:14:50 -06:00
Rose
45fdfa18f1
Mark functions not returning as sudo_noreturn
...
We also put NOTREACHED where it applies.
2023-07-01 17:40:16 -04:00
Rose
22079c3072
Avoid compiler casting warnings Part 2
...
This saves instructions that are related to casting as well as compiler warnings.
2023-06-29 13:10:27 -04:00
Todd C. Miller
1ba61cd13a
No need to round up to page size with sudo_mmap_alloc().
2023-06-29 10:17:39 -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
Rose
7fd680c983
Do variable length arrays the C99 way
...
Variable length arrays are supported by C99, but having it denoted as "1" confused the compiler and is not defined.
Note that because we don't get the inferred NULL terminator, we have to increase the malloc size by one.
2023-06-15 15:25:17 -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
95cd409079
Make suspend_parent.c out of lib/util and into src.
...
Nothing else uses it now.
2023-06-04 19:08:52 -06:00
Todd C. Miller
cda03ed13f
Back out last change, len must be int, not size_t, for %.*s.
2023-05-03 13:36:07 -06:00
Rose
459a49b1fe
Prefer size_t over int, as casting can take extra instructions
2023-05-03 15:18:05 -04:00
Todd C. Miller
d4c6ef1222
Add adminconfdir and --enable-adminconf to set it.
...
Configuration paths in sudo are now a colon-separated list of files
with the adminconfdir instance first (if enabled), followed by a
sysconfdir instance.
2023-05-02 10:37:39 -06:00
Todd C. Miller
4363d03ef7
Convert config file paths to colon-separated path list.
...
This means that _PATH_SUDO_CONF, _PATH_SUDOERS, _PATH_SUDO_LOGSRVD_CONF,
and _PATH_CVTSUDOERS_CONF can now specify multiple files. The first
file that exists is used.
2023-05-02 10:37:38 -06:00
Todd C. Miller
80b85bdd50
get_user_info: call sudo_get_ttysize() even if no /dev/tty
...
We still want to initialize rows and cols based on the environment
if possible.
2023-04-17 07:27:05 -06:00
Todd C. Miller
cc22cca34f
Add an fd argument to sudo_get_ttysize() instead of always using stderr.
...
For sudoreplay we open /dev/tty, so use that instead of stderr when
determining the terminal size.
2023-04-16 15:45:19 -06:00
Todd C. Miller
5650b436e6
Check whether stderr is a tty before trying TIOCGWINSZ.
2023-04-16 15:31:14 -06:00
Todd C. Miller
3e734fa51b
Correct a comment.
2023-03-23 08:20:48 -06:00
Todd C. Miller
f5d0b7abf7
Remove portable getcwd.c, nothing uses it anymore.
...
Any operating system supported by sudo already includes getcwd(3).
2023-03-16 15:01:41 -06:00
Todd C. Miller
708cdc61ba
nanosleep: clear remainder on successful completion
...
Also switch to doing everything in terms of struct timespec except
for the actual select(2) call.
2023-03-15 13:50:33 -06:00
Todd C. Miller
cb7b1dd89c
Pass closure to callback, not the callback pointer itself.
2023-03-10 11:19:37 -07:00
bin-ly
ec255dca1e
fix command error for lib/util/Makefile.in
2023-03-09 10:10:45 +08:00
Todd C. Miller
dea110a848
Add tests for SHA2 digest support.
...
This uses the NIST byte-oriented short message test vectors.
2023-03-07 12:45:13 -07: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
8bb1160624
Replace LIBMD with LIBCRYPTO display crypto/tls libs in summary.
...
We can only have one of either -lmd, -lgcrypt or -lcrypto so there
is no need to have more than one variable.
2023-02-22 08:49:33 -07:00
Todd C. Miller
0339337103
Run the editor in its own process group.
...
This fixes suspending the editor on GNU Hurd which doesn't seem to
have proper process group signal handling.
2023-02-21 16:14:14 -07:00
Todd C. Miller
0443d14578
Add checks for realpath(3) and a version from NetBSD for those without it.
2023-02-12 13:27:17 -07:00
Todd C. Miller
2845ceafb0
Handle "locale -a" returning both C.UTF-8 and C.utf8.
...
It is possible to have mutiple matches from the output of "locale
-a". Just take the first one. Fixes GitHub issue #241 .
2023-02-15 13:49:04 -07:00
Todd C. Miller
4f50692acc
Add some missing files to the clean and distclean targets.
2023-02-15 10:22:42 -07:00
Todd C. Miller
e63eeee7b4
Add debug tracing to tcsetattr_nobg().
2023-02-02 09:31:25 -07:00
Todd C. Miller
6d945448ef
Merge pull request #230 from trackers-lover/main
...
Return value does not match
2023-01-29 07:12:25 -07:00
bianguangze@uniontech.com
8797f0ceb9
Modify return value parameter
2023-01-29 11:08:38 +08:00
Todd C. Miller
e11bb93e26
Add tests for escaped digits.
2023-01-23 08:48:21 -07:00
Todd C. Miller
f6340068d1
check_pattern: handle escaped digits since GNU libc accepts them.
2023-01-23 08:02:25 -07:00
Todd C. Miller
ee2f2287a6
check_pattern: accept a backslash before the numeric bound like glibc.
...
This helps avoid out-of-memory conditions when fuzzing on Linux.
2023-01-19 19:50:09 -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
trackers-love
326f013cfa
Return value does not match
2023-01-17 12:24:45 +08:00
Todd C. Miller
0b2f9cbe7c
In SHA256Pad and SHA512Pad use 511 and 1023 respectively for bitwise AND.
...
Previously we were using 504 and 1016 which still produces the
correct result since padding is done in 8-bit bytes. However, using
size-1 for the bitwise AND makes the intent clearer and likely would
have prevented the previous bug in SHA512Pad.
From Matthieu Barjole and Victor Cutillas of Synacktiv (https://synacktiv.com )
2023-01-09 14:37:47 -07:00