At 19:28 +0000 05 Oct 2013, Michael Elkins <[email protected]> wrote:
On Thu, Aug 22, 2013 at 03:10:36PM -0400, Aaron Schrab wrote:
Indeed, I'd already completed the following patch before seeing this message. It replaces use of memset with mutt_buffer_init. Even if there's a later move to do more in another initialization function, being able to search for uses of mutt_buffer_init rather than needing to search for memset will make that easier.

Applied.  http://dev.mutt.org/trac/changeset/6308

Great. Unfortunately it appears that the first portion of the set wasn't applied, and that's the one that actually fixed the problem in the subject. The one that was applied was essentially just a cleanup. Sorry that I apparently wasn't more clear about that, there were probably some conflicts applying this one without the other being applied first.

Here's a new version of that first patch adjusted to apply after the other one.

---------- 8< ---------------
Subject: [PATCH] Initialize BUFFER variables

Ensure that BUFFER variables are initialized to prevent later attempts
to traverse an uninitialized pointer.
---
commands.c     |    1 +
hook.c         |    7 +++++--
imap/command.c |    1 +
imap/imap.c    |    1 +
4 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/commands.c b/commands.c
index 68cfe27..6b23e39 100644
--- a/commands.c
+++ b/commands.c
@@ -617,6 +617,7 @@ void mutt_enter_command (void)
  buffer[0] = 0;
  if (mutt_get_field (":", buffer, sizeof (buffer), M_COMMAND) != 0 || 
!buffer[0])
    return;
+  mutt_buffer_init (&err);
  err.dsize = STRING;
  err.data = safe_malloc(err.dsize);
  mutt_buffer_init (&token);
diff --git a/hook.c b/hook.c
index 6e881ef..34f3106 100644
--- a/hook.c
+++ b/hook.c
@@ -281,7 +281,8 @@ void mutt_folder_hook (char *path)
  BUFFER err, token;

  current_hook_type = M_FOLDERHOOK;
- +
+  mutt_buffer_init (&err);
  err.dsize = STRING;
  err.data = safe_malloc (err.dsize);
  mutt_buffer_init (&token);
@@ -332,7 +333,8 @@ void mutt_message_hook (CONTEXT *ctx, HEADER *hdr, int type)
  HOOK *hook;

  current_hook_type = type;
- +
+  mutt_buffer_init (&err);
  err.dsize = STRING;
  err.data = safe_malloc (err.dsize);
  mutt_buffer_init (&token);
@@ -476,6 +478,7 @@ void mutt_account_hook (const char* url)
  if (inhook)
    return;

+  mutt_buffer_init (&err);
  err.dsize = STRING;
  err.data = safe_malloc (err.dsize);
  mutt_buffer_init (&token);
diff --git a/imap/command.c b/imap/command.c
index 092cf59..32f8417 100644
--- a/imap/command.c
+++ b/imap/command.c
@@ -778,6 +778,7 @@ static void cmd_parse_lsub (IMAP_DATA* idata, char* s)
  url_ciss_tostring (&url, buf + 11, sizeof (buf) - 10, 0);
  safe_strcat (buf, sizeof (buf), "\"");
  mutt_buffer_init (&token);
+  mutt_buffer_init (&err);
  err.data = errstr;
  err.dsize = sizeof (errstr);
  if (mutt_parse_rc_line (buf, &token, &err))
diff --git a/imap/imap.c b/imap/imap.c
index 5173357..93dc06a 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -1828,6 +1828,7 @@ int imap_subscribe (char *path, int subscribe)
  if (option (OPTIMAPCHECKSUBSCRIBED))
  {
    mutt_buffer_init (&token);
+    mutt_buffer_init (&err);
    err.data = errstr;
    err.dsize = sizeof (errstr);
    snprintf (mbox, sizeof (mbox), "%smailboxes \"%s\"",
--
1.7.10.4

Reply via email to