18 Commits

Author SHA1 Message Date
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
5768d374cc libsudo_util: silence most -Wconversion warnings. 2023-07-07 15:07:04 -06:00
Todd C. Miller
0cb3835111 sudo_open_parent_dir: adjust loop terminating condition
Checking for ep < pathend should be a bit clearer than ep != '\0'
and has the advantage of working when pathend doesn't point to a
NUL byte.  No intended change in behavior.
2023-01-03 15:22:29 -07:00
Todd C. Miller
719b7f933f sudo_open_parent_dir: stop before creating the last path component
Fix a regression introduced in sudo 1.9.9 where the entire directory
path was created instead of just the parent directory.
2022-10-04 08:51:36 -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
cbd52e705c Fix potential TOCTOU when creating time stamp directory and file. 2022-09-21 19:08:09 -06:00
Todd C. Miller
8c482bfeb2 sudo_mkdir_parents: just use memcpy() to copy the path component.
Using snprintf() for this is overkill, we need to do the same
length check either way.
2022-09-21 19:06:53 -06:00
Todd C. Miller
1afce22f7f Use PATH_MAX, not NAME_MAX+1 for the directory entry length.
On some systems, such as Solaris, the max length of a directory
entry is filesystem-dependent.  We could use fpathconf() and
dynamically allocate the name but it is simpler to just use
PATH_MAX here.
2022-01-12 15:30:39 -07:00
Todd C. Miller
1f098a2029 Use POSIX NAME_MAX, not the obsolete MAXNAMLEN define.
Fixes compilation with musl libc.
2022-01-12 10:25:44 -07:00
Todd C. Miller
c53192eb7e sudo_mkdir_parents: make sure the path we created is a directory
For extra paranoia, verify that the directory we created is still
a directory before we fchown() it.
2021-12-11 16:27:33 -07:00
Todd C. Miller
c13b21c199 Avoid TOCTOU in sudo_mkdir_parents() using openat(2) and mkdirat(2).
This also allows us to make path const as it should be.
2021-12-11 08:35:18 -07:00
Todd C. Miller
a7367ce47d Move cppcheck suppression annotation to where it needs to be. 2021-09-22 15:51:45 -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
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
6c6f0567ba Avoid TOCTOU in sudo_mkdir_parents; Coverity CID 204357 2019-10-24 20:04:32 -06:00
Todd C. Miller
e0c9a9dfa3 Move mkdir_parents to libsudo_util. 2019-10-24 20:04:31 -06:00