Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-09-25 17:48:19 +0300
committerEdward Thomson <ethomson@github.com>2016-05-26 21:01:07 +0300
commit8cb27223b8eda4767179a1f226f96d2bdec2fe44 (patch)
tree3c0d776eaa465e7f875b02c27eed56fa01170ad8 /src/buffer.c
parent0267c34c0cbcdd3b5935d5988d572564dbe5d939 (diff)
git_buf_quote/unquote: handle > \177
Parse values up to and including `\377` (`0xff`) when unquoting. Print octal values as an unsigned char when quoting, lest `printf` think we're talking about negatives.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 31341c4b5..d135ebe4a 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -901,7 +901,7 @@ int git_buf_quote(git_buf *buf)
/* escape anything unprintable as octal */
else if (buf->ptr[i] != ' ' &&
(buf->ptr[i] < '!' || buf->ptr[i] > '~')) {
- git_buf_printf(&quoted, "\\%03o", buf->ptr[i]);
+ git_buf_printf(&quoted, "\\%03o", (unsigned char)buf->ptr[i]);
}
/* yay, printable! */
@@ -959,7 +959,7 @@ int git_buf_unquote(git_buf *buf)
case 'v': ch = '\v'; break;
/* \xyz digits convert to the char*/
- case '0': case '1': case '2':
+ case '0': case '1': case '2': case '3':
if (j == buf->size-3) {
giterr_set(GITERR_INVALID,
"Truncated quoted character \\%c", ch);