[systemd-devel] [PATCH] shorten_uuid: use proper table size

Maciej Wereski m.wereski at partner.samsung.com
Wed May 28 02:24:44 PDT 2014


16.05.2014 at 16:41 Lennart Poettering <lennart at poettering.net> wrote:

> On Fri, 16.05.14 11:00, Maciej Wereski (m.wereski at partner.samsung.com)  
> wrote:
>
>> ---
>>  src/core/machine-id-setup.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c
>> index 2a58e48..0544117 100644
>> --- a/src/core/machine-id-setup.c
>> +++ b/src/core/machine-id-setup.c
>> @@ -38,7 +38,7 @@
>>  #include "fileio.h"
>>  #include "path-util.h"
>>
>> -static int shorten_uuid(char destination[36], const char *source) {
>> +static int shorten_uuid(char destination[34], const char *source) {
>>          unsigned i, j;
>>
>>          for (i = 0, j = 0; i < 36 && j < 32; i++) {
>
> Hmm? This patch doesn't look right.
>
> When the function is called the buffer is filled with 36 chars, and we
> then strip the non-hex-chars, so that 34 chars result. But the function
> signature should still indicate that we need 36 chars initially..
>
> Lennart

Well, i (< 36) is used for source and j (< 32) is used for destination.
After the loop destination[32] and destination[33] is set. Also
shorten_uuid() is used in two places, where id[34] is passed as
destination. So it looked for me like destination should be 34.

regards,
-- 
Maciej Wereski
Samsung R&D Institute Poland
Samsung Electronics
m.wereski at partner.samsung.com


More information about the systemd-devel mailing list