47 lines
1.2 KiB
Diff
47 lines
1.2 KiB
Diff
From 4faba3de2ad22c84608a1e1d13d2578d7f0faee9 Mon Sep 17 00:00:00 2001
|
|
From: Rainer Gerhards <rgerhards@adiscon.com>
|
|
Date: Wed, 28 May 2014 17:19:28 +0200
|
|
Subject: [PATCH 05/30] fix problems with trailing incomplete hex sequence
|
|
|
|
---
|
|
src/string.c | 8 ++++++++
|
|
1 file changed, 8 insertions(+)
|
|
|
|
diff --git a/src/string.c b/src/string.c
|
|
index 36256fd..f1fb6b1 100644
|
|
--- a/src/string.c
|
|
+++ b/src/string.c
|
|
@@ -1,3 +1,4 @@
|
|
+#include <stdio.h>
|
|
/**
|
|
* @file string.c
|
|
* Implements string handling
|
|
@@ -696,10 +697,16 @@ doUnescape(unsigned char *c, es_size_t lenStr, es_size_t *iSrc, es_size_t iDst)
|
|
c[iDst] = '\\';
|
|
break;
|
|
case 'x':
|
|
+ if((*iSrc)+1 == lenStr) {
|
|
+ /* just end run, leave as is */
|
|
+ *iSrc += 1;
|
|
+ goto done;
|
|
+ }
|
|
if( (*iSrc)+2 == lenStr
|
|
|| !isxdigit(c[(*iSrc)+1])
|
|
|| !isxdigit(c[(*iSrc)+2])) {
|
|
/* error, incomplete escape, use as is */
|
|
+ printf("error: incomplete 2 x escape\n");
|
|
c[iDst] = '\\';
|
|
--(*iSrc);
|
|
}
|
|
@@ -720,6 +727,7 @@ doUnescape(unsigned char *c, es_size_t lenStr, es_size_t *iSrc, es_size_t iDst)
|
|
/* regular character */
|
|
c[iDst] = c[*iSrc];
|
|
}
|
|
+done: return;
|
|
}
|
|
|
|
void
|
|
--
|
|
1.8.3.1
|
|
|