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
master
David Lawrence Ramsey 2006-11-27 04:35:11 +00:00
parent 50d78a6f9a
commit 013613ec40
2 changed files with 18 additions and 4 deletions

View File

@ -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)

View File

@ -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) {