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:
authorAnders Borum <anders@algoritmer.dk>2015-08-05 19:50:25 +0300
committerAnders Borum <anders@algoritmer.dk>2015-08-17 08:58:31 +0300
commit2d1d2bb59f88956b894a6cdb002bc52a2528e4a8 (patch)
tree6ae58b112f35bd59cdc727212172385a3b1a20b4
parentcf716beed2f4729cf01a9822d75b4f1ebf7ccbf1 (diff)
Include the 4 characters not recognised as hex-number when setting error in parse_len
-rw-r--r--src/transports/smart_pkt.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/transports/smart_pkt.c b/src/transports/smart_pkt.c
index 9ccbd8085..a6ae55d48 100644
--- a/src/transports/smart_pkt.c
+++ b/src/transports/smart_pkt.c
@@ -351,7 +351,7 @@ static int unpack_pkt(git_pkt **out, const char *line, size_t len)
static int32_t parse_len(const char *line)
{
char num[PKT_LEN_SIZE + 1];
- int i, error;
+ int i, k, error;
int32_t len;
const char *num_end;
@@ -360,7 +360,14 @@ static int32_t parse_len(const char *line)
for (i = 0; i < PKT_LEN_SIZE; ++i) {
if (!isxdigit(num[i])) {
- giterr_set(GITERR_NET, "Found invalid hex digit in length");
+ /* Make sure there are no special characters before passing to error message */
+ for (k = 0; k < PKT_LEN_SIZE; ++k) {
+ if(!isprint(num[k])) {
+ num[k] = '.';
+ }
+ }
+
+ giterr_set(GITERR_NET, "invalid hex digit in length: '%s'", num);
return -1;
}
}