]> git.ipfire.org Git - thirdparty/make.git/commitdiff
* read.c (unescape_char): [SV 45050] Handle final backslashes.
authorPaul Smith <psmith@gnu.org>
Sun, 12 Jul 2015 16:35:42 +0000 (12:35 -0400)
committerPaul Smith <psmith@gnu.org>
Sun, 12 Jul 2015 16:39:59 +0000 (12:39 -0400)
If the last thing in the string to be unescaped is a backslash,
stop without reading beyond the end of the string.

read.c

diff --git a/read.c b/read.c
index e67d386ef4a2297a17732a3bb67838bec92ed801..2b5f08d11183e627a28e4a81543eb447a3d45311 100644 (file)
--- a/read.c
+++ b/read.c
@@ -2343,6 +2343,10 @@ unescape_char (char *string, int c)
               /* It's not; just take it all without unescaping.  */
               memmove (p, s, l);
               p += l;
+
+              // If we hit the end of the string, we're done
+              if (*e == '\0')
+                break;
             }
           else if (l > 1)
             {
@@ -2351,6 +2355,7 @@ unescape_char (char *string, int c)
               memmove (p, s, l);
               p += l;
             }
+
           s = e;
         }