qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gordon Sim <g...@redhat.com>
Subject Re: qpid-proton git commit: PROTON-911: Implemented encryption/decryption functionality for Cyrus SASL
Date Thu, 02 Jul 2015 13:33:52 GMT
On 07/01/2015 08:42 PM, astitcher@apache.org wrote:
> Repository: qpid-proton
> Updated Branches:
>    refs/heads/master c78392f19 -> 395b23f5f
>
>
> PROTON-911: Implemented encryption/decryption functionality for Cyrus SASL
[...]
> Committer: Andrew Stitcher <astitcher@apache.org>
> Committed: Wed Jul 1 14:29:46 2015 -0400
[...]
> @@ -343,12 +367,23 @@ static ssize_t pn_output_write_sasl(pn_transport_t* transport,
unsigned int laye
>
>   static ssize_t pn_output_write_sasl_encrypt(pn_transport_t* transport, unsigned int
layer, char* bytes, size_t available)
>   {
> -  ssize_t size = pni_passthru_layer.process_output(transport, layer, bytes, available
);
> -  if (size<=0) return size;
> +  ssize_t clear_size = pni_passthru_layer.process_output(transport, layer, bytes, available
);
> +  if (clear_size<0) return clear_size;
>
> +  const ssize_t max_buffer = transport->sasl->max_encrypt_size;
>     pn_buffer_t *out = transport->sasl->encoded_buffer;
> -  pni_sasl_impl_encode(transport, pn_bytes(size, bytes), out);
> -  size = pn_buffer_get(out, 0, available, bytes);
> +  for (ssize_t processed = 0; processed<clear_size;) {
> +    pn_bytes_t encoded = pn_bytes(0, NULL);
> +    ssize_t encode_size = (clear_size-processed)<=max_buffer?(clear_size-processed):max_buffer;
> +    size_t size = pni_sasl_impl_encode(transport, pn_bytes(encode_size, bytes+processed),
&encoded);
> +    if (size<0) return size;

This test makes no sense as size_t is unsigned so the value can never be 
negative. Clang complains.

> +    if (size>0) {
> +      size = pn_buffer_append(out, encoded.start, encoded.size);
> +      if (size) return size;
> +    }
> +    processed += encode_size;
> +  }
> +  ssize_t size = pn_buffer_get(out, 0, available, bytes);
>     pn_buffer_trim(out, size, 0);
>     return size;
>   }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org


Mime
View raw message