Re: [PATCH v8 4/7] ima: define a new template field named 'd-ngv2' and templates

From: Mimi Zohar
Date: Fri Apr 29 2022 - 17:41:19 EST


On Fri, 2022-04-29 at 11:09 -0400, Stefan Berger wrote:
> > - if (hash_algo < HASH_ALGO__LAST) {
> > + if (digest_type < DIGEST_TYPE__LAST && hash_algo < HASH_ALGO__LAST) {
> > + fmt = DATA_FMT_DIGEST_WITH_TYPE_AND_ALGO;
> > + offset += 1 + sprintf(buffer, "%*s:%*s:",
> > + (int)strlen(digest_type_name[digest_type]),
> > + digest_type_name[digest_type],
> > + (int)strlen(hash_algo_name[hash_algo]),
> > + hash_algo_name[hash_algo]);
>
> '%*s' seems to be for right-alignment but only makes sense if the length
> indicator is different than then following string. sprintf(buffer,
> "|%*s|",5,"test") prints | test|. Otherwise it seems to behave like
> plain '%s' in this case... ?

Re-testing now, it works properly without the length.

thanks,

Mimi