[haiku-commits] haiku: hrev47078 - src/kits/network/libnetapi

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 31 Mar 2014 10:00:36 +0200 (CEST)

hrev47078 adds 1 changeset to branch 'master'
old head: aec5be7aa21ceb13a74ea78bb489936020082817
new head: 943b310c90ad5e96395c4d33cb996774959a1cda
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=943b310+%5Eaec5be7

----------------------------------------------------------------------------

943b310: Data URLs: fix size computation.
  
  The decoded data is 3/4 the size of base64 encoded, not 4/3.

                             [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev47078
Commit:      943b310c90ad5e96395c4d33cb996774959a1cda
URL:         http://cgit.haiku-os.org/haiku/commit/?id=943b310
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Mon Mar 31 07:59:12 2014 UTC

----------------------------------------------------------------------------

1 file changed, 3 insertions(+), 3 deletions(-)
src/kits/network/libnetapi/DataRequest.cpp | 6 +++---

----------------------------------------------------------------------------

diff --git a/src/kits/network/libnetapi/DataRequest.cpp 
b/src/kits/network/libnetapi/DataRequest.cpp
index b2fd900..4b394d9 100644
--- a/src/kits/network/libnetapi/DataRequest.cpp
+++ b/src/kits/network/libnetapi/DataRequest.cpp
@@ -81,7 +81,7 @@ BDataRequest::_ProtocolLoop()
        }
 
        if (isBase64) {
-               char* buffer = new char[data.Length() * 4 / 3];
+               char* buffer = new char[data.Length() * 3 / 4];
                payload = buffer;
                        // payload must be a const char* so we can assign 
data.String() to
                        // it below, but decode_64 modifies buffer.
@@ -90,8 +90,8 @@ BDataRequest::_ProtocolLoop()
                // There may be some padding at the end of the base64 stream. 
This
                // prevents us from computing the exact length we should get, 
so allow
                // for some error margin.
-               if(length > data.Length() * 4 / 3
-                       || length < data.Length() * 4 / 3 - 3) {
+               if(length > data.Length() * 3 / 4
+                       || length < data.Length() * 3 / 4 - 3) {
                        delete[] buffer;
                        return B_BAD_DATA;
                }


Other related posts:

  • » [haiku-commits] haiku: hrev47078 - src/kits/network/libnetapi - pulkomandy