mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-20 19:07:48 +00:00
Merge pull request #3355 from palmin/palmin/fix-2830
Include the 4 characters not recognised as hex-number in parse_len
This commit is contained in:
commit
1947592461
@ -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)
|
static int32_t parse_len(const char *line)
|
||||||
{
|
{
|
||||||
char num[PKT_LEN_SIZE + 1];
|
char num[PKT_LEN_SIZE + 1];
|
||||||
int i, error;
|
int i, k, error;
|
||||||
int32_t len;
|
int32_t len;
|
||||||
const char *num_end;
|
const char *num_end;
|
||||||
|
|
||||||
@ -360,7 +360,14 @@ static int32_t parse_len(const char *line)
|
|||||||
|
|
||||||
for (i = 0; i < PKT_LEN_SIZE; ++i) {
|
for (i = 0; i < PKT_LEN_SIZE; ++i) {
|
||||||
if (!isxdigit(num[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;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user