[OpenWrt-Devel] [PATCH 1/3] [rpcd] file: add md5sum support

Jonas Gorski jogo at openwrt.org
Mon Mar 16 13:53:50 EDT 2015


Hi,

On Mon, Mar 16, 2015 at 6:47 PM, Luka Perkov <luka at openwrt.org> wrote:
> Hi John,
>
> On Sun, Mar 15, 2015 at 10:21:27PM +0100, John Crispin wrote:
>> On 15/03/2015 22:00, Luka Perkov wrote:
>> > wbuf = blobmsg_alloc_string_buffer(&buf, "md5", 33);
>> > +
>> > +   for (i = 0; i < 16; i++)
>> > +           sprintf((wbuf + (i * 2)), "%02x", (uint8_t) md5[i]);
>>
>> there is a set of brackets too many here
>
> Ok. I've fixed it locally.
>
>> > +   *(wbuf + 33) = 0;
>>
>> is this not off by 1 ?
>
> No.
>
>> if we want to be pedantic it should also be '\0'
>>
>> i think wbuf[32] = '\0'; is a saner syntax
>
> Ok. I've queued this for v2 which I will send after libubox base64
> patch.

sprintf null-terminates the generated string, so the 16th sprintf()
will already have set wbuf[33] to \0.


Jonas
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list