]> granicus.if.org Git - neomutt/commitdiff
Avoid reading past the end of ta string when handling \ or ^
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 15 Jan 2002 18:22:05 +0000 (18:22 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 15 Jan 2002 18:22:05 +0000 (18:22 +0000)
sequences.  From Michael Elkins.

init.c

diff --git a/init.c b/init.c
index 53470991908486ee21da431163a2f444c270441a..a96bc049ae98d8d1167d3ca65ab53639825d09ec 100644 (file)
--- a/init.c
+++ b/init.c
@@ -135,10 +135,14 @@ int mutt_extract_token (BUFFER *dest, BUFFER *tok, int flags)
       qc = ch;
     else if (ch == '\\' && qc != '\'')
     {
+       if (!*tok->dptr)
+           return -1; /* premature end of token */
       switch (ch = *tok->dptr++)
       {
        case 'c':
        case 'C':
+           if (!*tok->dptr)
+               return -1; /* premature end of token */
          mutt_buffer_addch (dest, (toupper (*tok->dptr) - '@') & 0x7f);
          tok->dptr++;
          break;
@@ -172,6 +176,8 @@ int mutt_extract_token (BUFFER *dest, BUFFER *tok, int flags)
     }
     else if (ch == '^' && (flags & M_TOKEN_CONDENSE))
     {
+       if (!*tok->dptr)
+           return -1; /* premature end of token */
       ch = *tok->dptr++;
       if (ch == '^')
        mutt_buffer_addch (dest, ch);