From b6dadceda39d452e56cfb0c65789c702253d2188 Mon Sep 17 00:00:00 2001 From: TLINDEN Date: Mon, 17 Mar 2014 19:15:04 +0100 Subject: [PATCH] fixed utf8 bug, which sometimes lead to z85 handling of pure binary data --- include/pcp.h | 1 + libpcp/pcpstream.c | 1 + libpcp/z85.c | 6 ++++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/pcp.h b/include/pcp.h index 8b16eae..fb0d6c6 100644 --- a/include/pcp.h +++ b/include/pcp.h @@ -8,6 +8,7 @@ extern "C" { #include "pcp/config.h" #include "pcp/base85.h" #include "pcp/buffer.h" +#include "pcp/config.h" #include "pcp/crypto.h" #include "pcp/defines.h" #include "pcp/digital_crc32.h" diff --git a/libpcp/pcpstream.c b/libpcp/pcpstream.c index 361b14c..6d355fc 100644 --- a/libpcp/pcpstream.c +++ b/libpcp/pcpstream.c @@ -331,6 +331,7 @@ void ps_determine(Pcpstream *stream) { /* check if it's binary or not */ if(_buffer_is_binary(buf, got) == 0) { + /* not binary, it's armored */ stream->armor = 1; diff --git a/libpcp/z85.c b/libpcp/z85.c index f250eb4..09ebdb2 100644 --- a/libpcp/z85.c +++ b/libpcp/z85.c @@ -101,7 +101,6 @@ size_t _buffer_is_binary(byte *buf, size_t len) { for (pos=1; pos 1) { pos += i; /* jump over the utf we already found */ utf = 1; + break; } } else break; } + memset(wide, 0, 4); if(utf == 1) { /* it's a utf8 char, continue checking, reset wide */ - memset(wide, 0, 4); + utf = 0; continue; } break; /* if we reach this, then it's binary and not utf8, stop checking */ } } + if(pos < len) return pos; /* binary */ else