From: David Lawrence Ramsey Date: Mon, 27 Nov 2006 04:35:11 +0000 (+0000) Subject: in do_insertfile(), properly handle executable commands that contain X-Git-Tag: v2.0.2~33 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=013613ec4052540bc9ea554786880cca7723888e;p=nano.git in do_insertfile(), properly handle executable commands that contain nulls git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3972 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 4d780001..e25222c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ CVS code - the "Insert File" prompt to contain nulls. Changes to do_statusbar_input(), do_statusbar_output(), and do_statusbar_verbatim_input(). (DLR) +- files.c: + do_insertfile() + - Properly handle executable commands that contain nulls. (DLR) - nano.h: - Rename NANO_ALT_REPLACE_KEY to NANO_REPLACE_ALTKEY, for consistency. (DLR) diff --git a/src/files.c b/src/files.c index 60d67980..793c9b28 100644 --- a/src/files.c +++ b/src/files.c @@ -294,8 +294,8 @@ filestruct *read_line(char *buf, filestruct *prevnode, bool { filestruct *fileptr = (filestruct *)nmalloc(sizeof(filestruct)); - /* Convert nulls to newlines. buf_len is the string's real length - * here. */ + /* Convert nulls to newlines. buf_len is the string's real + * length. */ unsunder(buf, buf_len); assert(openfile->fileage != NULL && strlen(buf) == buf_len); @@ -802,15 +802,25 @@ void do_insertfile( #ifndef NANO_TINY if (execute) { + size_t answer_len = strlen(answer); + #ifdef ENABLE_MULTIBUFFER if (ISSET(MULTIBUFFER)) /* Open a blank buffer. */ open_buffer(""); #endif + /* Convert newlines to nulls, just before we execute a + * command. */ + sunder(answer); + /* Save the command's output in the current buffer. */ execute_command(answer); + /* Convert nulls to newlines. answer_len is answer's + * real length. */ + unsunder(answer, answer_len); + #ifdef ENABLE_MULTIBUFFER if (ISSET(MULTIBUFFER)) { /* Move back to the beginning of the first line of @@ -1564,12 +1574,13 @@ int write_file(const char *name, FILE *f_open, bool tmp, append_type while (fileptr != NULL) { size_t data_len = strlen(fileptr->data), size; - /* Newlines to nulls, just before we write to disk. */ + /* Convert newlines to nulls, just before we write to disk. */ sunder(fileptr->data); size = fwrite(fileptr->data, sizeof(char), data_len, f); - /* Nulls to newlines; data_len is the string's real length. */ + /* Convert nulls to newlines. data_len is the string's real + * length. */ unsunder(fileptr->data, data_len); if (size < data_len) {