[OTR-dev] otrl_base64_otr_decode() function...

Ian Goldberg ian at cypherpunks.ca
Tue Jul 17 14:56:14 EDT 2012


On Tue, Jul 17, 2012 at 10:39:39PM -0400, Paul Wouters wrote:
> On Tue, 17 Jul 2012, Ian Goldberg wrote:
> 
> >@@ -237,7 +237,7 @@ int otrl_base64_otr_decode(const char *msg, unsigned char **
> >    }
> >
> >    /* Base64-decode the message */
> >-    rawlen = ((msglen-5) / 4) * 3;   /* maximum possible */
> >+    rawlen = ((msglen-5+3) / 4) * 3;   /* maximum possible */
> >    rawmsg = malloc(rawlen);
> >    if (!rawmsg && rawlen > 0) {
> >       return -1;
> 
> Personally, I prefer things like sizeof("===") over literals like '3'.

The "3" is actually "4-1", as the way to write ceil(x/4) in C (with
integer arithmetic) is (x+3)/4.

   - Ian



More information about the OTR-dev mailing list