c1ed913d71
- add patch that resolves initialization problem before call sudo_strsplit - add patch that resolves deadcode in visudo.c
41 lines
1.6 KiB
Diff
41 lines
1.6 KiB
Diff
diff -up ./plugins/sudoers/visudo.c.deadcode ./plugins/sudoers/visudo.c
|
|
--- ./plugins/sudoers/visudo.c.deadcode 2015-08-24 09:54:59.216956064 +0200
|
|
+++ ./plugins/sudoers/visudo.c 2015-08-24 09:59:50.831547773 +0200
|
|
@@ -415,12 +415,10 @@ edit_sudoers(struct sudoersfile *sp, cha
|
|
int tfd; /* sudoers temp file descriptor */
|
|
bool modified; /* was the file modified? */
|
|
int ac; /* argument count */
|
|
- char buf[4096]; /* buffer used for copying files */
|
|
char linestr[64]; /* string version of lineno */
|
|
struct timespec ts, times[2]; /* time before and after edit */
|
|
struct timespec orig_mtim; /* starting mtime of sudoers file */
|
|
off_t orig_size; /* starting size of sudoers file */
|
|
- ssize_t nread; /* number of bytes read */
|
|
struct stat sb; /* stat buffer */
|
|
bool rval = false; /* return value */
|
|
debug_decl(edit_sudoers, SUDOERS_DEBUG_UTIL)
|
|
@@ -440,15 +438,19 @@ edit_sudoers(struct sudoersfile *sp, cha
|
|
|
|
/* Copy sp->path -> sp->tpath and reset the mtime. */
|
|
if (orig_size != 0) {
|
|
+ char buf[4096], lastch = '\0';
|
|
+ ssize_t nread;
|
|
(void) lseek(sp->fd, (off_t)0, SEEK_SET);
|
|
- while ((nread = read(sp->fd, buf, sizeof(buf))) > 0)
|
|
+ while ((nread = read(sp->fd, buf, sizeof(buf))) > 0){
|
|
if (write(tfd, buf, nread) != nread)
|
|
sudo_fatal(U_("write error"));
|
|
+ lastch = buf[nread - 1];
|
|
+ }
|
|
|
|
/* Add missing newline at EOF if needed. */
|
|
- if (nread > 0 && buf[nread - 1] != '\n') {
|
|
- buf[0] = '\n';
|
|
- if (write(tfd, buf, 1) != 1)
|
|
+ if (lastch != '\n') {
|
|
+ lastch = '\n';
|
|
+ if (write(tfd, &lastch, 1) != 1)
|
|
sudo_fatal(U_("write error"));
|
|
}
|
|
}
|