[Replicant] [libsamsung-ipc] [PATCH 2/3] rfs: fix sign comparison

Joonas Kylmälä joonas.kylmala at iki.fi
Tue Dec 1 17:56:58 UTC 2020


Thanks, in this case we should then compare

st.st_size != 2 * MD5_DIGEST_LENGTH

It would be good to also put the 2 * MD5_DIGEST_LENGTH to some header as
MD5_DIGEST_LENGTH_ASCII. Then it could be simply:

st.st_size != MD5_DIGEST_LENGTH_ASCII

I have not tried yet but I could send patch for this.

Joonas

Denis 'GNUtoo' Carikli:
> On Sun, 29 Nov 2020 15:00:38 +0200
> Joonas Kylmälä <joonas.kylmala at iki.fi> wrote:
> 
>> Any idea why are we not just checking st.st_size == MD5_DIGEST_LENGTH
>> ? If we don't check that the data that exists on the file is not the
>> same length then we end up just comparing the first MD5_DIGEST_LENGTH
>> / 16 bytes.
> Good question: I didn't look at that when working on that patch.
> 
> It's because the md5 is stored as text inside the nv_data.bin.md5
>> $ cat nv_data.bin.md5 ; echo
>> 90e82ca32a48369b33f6f64955443fa9
>> $ file nv_data.bin.md5
>> nv_data.bin.md5: ASCII text, with no line terminators
> So each characters takes 8 bit (ASCII).
> 
> So with that nv_data.bin.md5 takes 32 bytes:
>> $ ls -l nv_data.bin.md5
>> -rw-r--r-- 1 gnutoo gnutoo 32 11 sept. 04:01 nv_data.bin.md5
> 
> If you were to encode that directly in binary, each "character" would
> take only 4 bits:
>> $ hexdump -C nv_data.bin.md5.bin 
>> 00000000  90 e8 2c a3 2a 48 36 9b  33 f6 f6 49 55 44 3f a9  |..,.*H6.3..IUD?.|
>> 00000010
> 
> $ ls -l nv_data.bin.md5.bin
> -rw-r--r-- 1 gnutoo gnutoo 16  1 déc.  12:30 nv_data.bin.md5.bin
> 
> Denis.
> 


More information about the Replicant mailing list