fixed catching of header string

This commit is contained in:
TLINDEN
2014-02-09 15:49:52 +01:00
parent ce73950920
commit 6829ea6fbc
8 changed files with 65 additions and 63 deletions

View File

@@ -68,7 +68,6 @@ void buffer_resize(Buffer *b, size_t len) {
if((b->end > 0 && b->end + len > b->size) || (b->end == 0 && len > b->size) ) {
/* increase by buf blocksize */
size_t newsize = (((len / b->blocksize) +1) * b->blocksize) + b->size;
fprintf(stderr, "[buffer %s] resizing from %ld to %ld\n", b->name, b->size, newsize);
b->buf = ucrealloc(b->buf, b->size, newsize);
b->size = newsize;
}

View File

@@ -73,10 +73,21 @@ unsigned char *pcp_z85_decode(char *z85block, size_t *dstlen) {
}
}
binlen = strlen (z85) * 4 / 5;
bin = ucmalloc(binlen);
bin = zmq_z85_decode(bin, z85);
if(bin == NULL) {
free(z85);
fatal("zmq_z85_decode() failed, input size ! % 5");
return NULL;
}
_dump("bin", bin, binlen);
fwrite(bin, 1, binlen, stderr);
unsigned char *raw = NULL;
if(bin != NULL) {
raw = pcp_unpadfour(bin, binlen, &outlen);
@@ -224,7 +235,7 @@ char *pcp_readz85string(unsigned char *input, size_t bufsize) {
}
}
if(buffer_size(line) > 0) {
if(buffer_size(line) > 0 && end != 1) {
/* something left in line buffer, probably
newline at eof missing or no multiline input */
buffer_add_buf(z, line);
@@ -238,8 +249,6 @@ char *pcp_readz85string(unsigned char *input, size_t bufsize) {
out = ucmalloc(buffer_size(z)+1);
strncpy(out, buffer_get_str(z), buffer_size(z)+1);
fprintf(stderr, "got: \n<%s>\n", out);
buffer_free(z);
buffer_free(line);