mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-22 09:57:41 +00:00
iolog_nextid(): make iolog_dir argument const.
We make a copy of the directory so there's no real reason that parameter can't be const.
This commit is contained in:
parent
0f2252f898
commit
23d04dde24
@ -111,7 +111,7 @@ bool iolog_close(struct iolog_file *iol, const char **errstr);
|
|||||||
bool iolog_eof(struct iolog_file *iol);
|
bool iolog_eof(struct iolog_file *iol);
|
||||||
bool iolog_mkdtemp(char *path);
|
bool iolog_mkdtemp(char *path);
|
||||||
bool iolog_mkpath(char *path);
|
bool iolog_mkpath(char *path);
|
||||||
bool iolog_nextid(char *iolog_dir, char sessid[7]);
|
bool iolog_nextid(const char *iolog_dir, char sessid[7]);
|
||||||
bool iolog_open(struct iolog_file *iol, int dfd, int iofd, const char *mode);
|
bool iolog_open(struct iolog_file *iol, int dfd, int iofd, const char *mode);
|
||||||
bool iolog_write_info_file(int dfd, struct eventlog *evlog);
|
bool iolog_write_info_file(int dfd, struct eventlog *evlog);
|
||||||
char *iolog_gets(struct iolog_file *iol, char *buf, size_t nbytes, const char **errsttr);
|
char *iolog_gets(struct iolog_file *iol, char *buf, size_t nbytes, const char **errsttr);
|
||||||
|
@ -50,11 +50,12 @@
|
|||||||
* Uses file locking to avoid sequence number collisions.
|
* Uses file locking to avoid sequence number collisions.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
iolog_nextid(char *iolog_dir, char sessid[7])
|
iolog_nextid(const char *iolog_dir, char sessid[7])
|
||||||
{
|
{
|
||||||
char buf[32], *ep;
|
char buf[32], *ep;
|
||||||
int i, len, fd = -1;
|
int i, fd = -1;
|
||||||
unsigned long id = 0;
|
unsigned long id = 0;
|
||||||
|
size_t len;
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
char pathbuf[PATH_MAX];
|
char pathbuf[PATH_MAX];
|
||||||
@ -66,14 +67,21 @@ iolog_nextid(char *iolog_dir, char sessid[7])
|
|||||||
/*
|
/*
|
||||||
* Create I/O log directory if it doesn't already exist.
|
* Create I/O log directory if it doesn't already exist.
|
||||||
*/
|
*/
|
||||||
if (!iolog_mkdirs(iolog_dir))
|
len = strlcpy(pathbuf, iolog_dir, sizeof(pathbuf));
|
||||||
|
if (len >= sizeof(pathbuf)) {
|
||||||
|
errno = ENAMETOOLONG;
|
||||||
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_ERRNO,
|
||||||
|
"%s: %s", __func__, iolog_dir);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
if (!iolog_mkdirs(pathbuf))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open sequence file
|
* Open sequence file
|
||||||
*/
|
*/
|
||||||
len = snprintf(pathbuf, sizeof(pathbuf), "%s/seq", iolog_dir);
|
len = strlcat(pathbuf, "/seq", sizeof(pathbuf));
|
||||||
if (len < 0 || len >= ssizeof(pathbuf)) {
|
if (len >= sizeof(pathbuf)) {
|
||||||
errno = ENAMETOOLONG;
|
errno = ENAMETOOLONG;
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_ERRNO,
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_ERRNO,
|
||||||
"%s: %s/seq", __func__, iolog_dir);
|
"%s: %s/seq", __func__, iolog_dir);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user