Todd C. Miller
0b03511b85
Log source in JSON logs
...
This makes it possible to tell which rule resulted in a match.
2023-08-08 09:56:19 -06:00
Todd C. Miller
1e6c5f3e79
Fix checking of SSL_{read,write}_ex() return value.
...
These have a boolean-style return value. However, our emulated
versions can return -1 on error, which we need to preserve for older
versions of SSL_get_error() which expect it.
2023-08-08 10:18:57 -06:00
Todd C. Miller
184e03b4a9
ERR_get_error() returns unsigned long, not int.
2023-08-07 08:05:00 -06:00
Todd C. Miller
d6d467b92e
Add implementation of SSL_read_ex/SSL_write_ex for those without.
2023-08-05 10:38:02 -06:00
Todd C. Miller
e6d14c95b6
Use SSL_read_ex() and SSL_write_ex() instead of SSL_read() and SSL_write().
2023-08-05 10:38:01 -06:00
Todd C. Miller
2eee45ef96
evlog_new: store a new copy of peeraddr, not a pointer to a buffer.
...
Starting in sudo 1.9.14, eventlog_free() will free the peeraddr
member too so it needs to be dynamically allocated.
2023-07-11 13:51:16 -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
4891f37a45
sudo_logsrvd: silence most -Wconversion warnings.
2023-07-07 15:07:04 -06:00
Todd C. Miller
f6d1542416
Move display of usage text into display_usage() so usage() always exits.
2023-07-04 19:47:28 -06:00
Todd C. Miller
1f0f6b7c78
Fix some indentation.
2023-07-04 18:03:47 -06: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
e95bd883d7
Promote length/size/offset in struct connection_buffer to size_t.
2023-07-03 17:02:24 -06:00
Todd C. Miller
56a431f7ea
Make sudo_pow2_roundup() operate on size_t.
2023-07-03 16:51:05 -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
Todd C. Miller
f437c66a2a
Merge pull request #265 from AtariDreams/types
...
Avoid compiler casting warnings by assigning to variables of the same type where possible
2023-06-29 10:06:30 -06:00
Rose
2c13d7130c
We should be returning 0, not 1, when logservd finishes without errors
...
1 is for failure, 0 is for no failure, and this does not look like a failure.
2023-06-28 17:27:13 -04: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
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
978aa90021
No longer need to set AI_NUMERICSERV while fuzzing.
...
Now that getaddrinfo() is stubbed out while fuzzing we can remove
the hack that set AI_NUMERICSERV.
2023-04-28 13:26:53 -06:00
Todd C. Miller
d1f2452c08
getaddrinfo stub: set sin_port
2023-04-26 16:27:34 -06:00
Todd C. Miller
2898c85119
Avoid NULL deref in stub getaddrinfo() when nodename is NULL.
...
Also add support for parsing servname. We only need to support a
subset of getaddrinfo() functionality in the fuzzer.
2023-04-26 13:23:31 -06:00
Todd C. Miller
47ae92d034
Include arpa/inet.h for inet_pton() prototype.
2023-04-25 13:22:02 -06:00
Todd C. Miller
3d4dc19ecd
Add netdb.h for struct addrinfo and EAI_* error codes.
2023-04-25 13:15:55 -06:00
Todd C. Miller
64f6d6fdbc
Stub out getaddrinfo() and freeaddrinfo().
...
We may not be able have access to DNS in the fuzzing environment.
2023-04-25 13:06:24 -06:00
Todd C. Miller
b013711e48
Check for sudo_pow2_roundup() overflow.
...
Calling sudo_pow2_roundup(INT_MAX+2) will return since there is no
power of 2 larger than INT_MAX+1 that fits in an unsigned int.
This is not an issue in practice since we restrict messages to 2Mib.
2023-03-01 13:58:32 -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
0b2e662b2e
Protect use of AF_INET6 with HAVE_STRUCT_IN6_ADDR guards.
...
From Tim Rice.
2023-01-31 12:22:47 -07:00
Todd C. Miller
49df977c2f
Avoid DNS lookups when fuzzing.
2023-01-31 08:59:50 -07:00
Todd C. Miller
91d7592e8a
Use initprogname(), not setprogname() in the fuzzers.
...
This results in better coverage for progname.c.
2022-12-29 15:52:21 -07:00
Todd C. Miller
797cc917a8
Add basic regress for JSON functions.
...
Fix a bug in escaped control character handling.
Roll back changes to buffer if sudo_json_add_value() fails.
2022-12-15 19:49:11 -07:00
Todd C. Miller
3df7b64d80
Fix failure in check targets when there is no UTF-8 C locale.
2022-12-06 16:26:34 -07:00
Todd C. Miller
a0d9963fe6
journal_fdopen: free journal_path and close journal before setting
...
Fixes a potential resource leak that currently cannot happen.
Quiets a warning from Infer.
2022-11-22 11:15:21 -07:00
Todd C. Miller
5683fc6f7a
The name of the C locale w/ UTF-8 support is not always C.UTF-8.
...
Use a pattern to find it (if present) and use that value instead
of hard-coding C.UTF-8. This works around a leak sanitizer crash
on certain inputs.
2022-11-11 07:05:21 -07:00
Todd C. Miller
57b5ff8e8c
Avoid a -Wshadow warning on Solaris 9.
2022-10-07 11:00:17 -06:00
Todd C. Miller
166e0e13bc
Change max user-ID and group-ID from INT_MAX to UINT_MAX.
2022-09-28 09:06:32 -06:00
Todd C. Miller
865d3cd0bb
Add support for NumberList stored in an InfoMessage.
2022-09-28 09:05:29 -06:00
Todd C. Miller
e6f2ad0ed6
Add missing NULL checks for mandatory fields in protobuf messages.
...
Also no longer reject an InfoMessage with an unknown value_case,
just log and ignore it.
2022-09-28 08:47:25 -06:00
Todd C. Miller
9d654482b2
Convert remaining uses of sudo_mkdir_parents() to sudo_open_parent_dir().
2022-09-21 19:08:15 -06:00
Todd C. Miller
a326411903
Use $(GREP) and $(EGREP) variables in Makefile.in files.
2022-09-12 16:30:52 -06:00
Todd C. Miller
f6e4d2765a
Add explicit include of unistd.h for getopt(3) and related variables.
2022-07-05 11:35:25 -06:00
Todd C. Miller
b6151781ce
Quiet some harmless PVS Studio warnings.
2022-06-29 10:08:55 -06:00
Todd C. Miller
54ed54d94e
Use "unable to allocate memory" warning on malloc failure.
...
This is consistent with the rest of the sudo source code.
2022-06-29 10:00:03 -06:00
Todd C. Miller
3e21c8da5c
Add missing PVS Studio Open Source comments.
...
Also avoid checking protobuf-c source and protobuf-c generated files.
2022-06-29 09:45:04 -06:00
Todd C. Miller
e5834bd405
Use #include <config.h> not #include "config.h" for consistency.
...
Otherwise, some compilers may do the wrong thing in a build
dir if there is a config.h file in the source dir too.
2022-06-29 08:47:16 -06:00
Todd C. Miller
13672f28df
Make sudo pass -Wwrite-strings
2022-06-28 16:33:15 -06:00
Todd C. Miller
f5ac1317c4
Make sudo pass -Wmissing-prototypes
2022-06-27 12:48:03 -06:00
Todd C. Miller
161b01fccd
Treat EINTR in a callback like we do EAGAIN.
...
We shouldn't get EINTR in practice since we set SA_RESTART when
registering signal handlers but it doesn't hurt to be consistent.
2022-06-07 09:25:07 -06:00
Todd C. Miller
db6fc237c4
If write(2) returns EAGAIN just re-enter the event loop.
...
This is consistent with how we handle EAGAIN for read(2).
2022-06-06 19:42:06 -06:00