Message ID | 20220512183056.307597-1-zohar@linux.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2,ima-evm-utils,1/3] initialize errno in cmd_sign_hash() | expand |
On 5/12/22 14:30, Mimi Zohar wrote: > Prevent "errno: No such file or directory (2)" message. I guess there's an error being returned from call_command() but this errno is unrelated or confusing. Maybe errno should be initialized at the beginning of main() or beginning of call_command() to clear it before any command is run that can return an error and where the errno may be confusing the user otherwise. > > Signed-off-by: Mimi Zohar <zohar@linux.ibm.com> > --- > src/evmctl.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/src/evmctl.c b/src/evmctl.c > index 8bdd34817408..ca9449498321 100644 > --- a/src/evmctl.c > +++ b/src/evmctl.c > @@ -737,6 +737,7 @@ static int cmd_sign_hash(struct command *cmd) > unsigned char sig[MAX_SIGNATURE_SIZE] = "\x03"; > int siglen; > > + errno = 0; > key = imaevm_params.keyfile ? : "/etc/keys/privkey_evm.pem"; > > /* support reading hash (eg. output of shasum) */
On Thu, 2022-05-12 at 15:14 -0400, Stefan Berger wrote: > > On 5/12/22 14:30, Mimi Zohar wrote: > > Prevent "errno: No such file or directory (2)" message. > > I guess there's an error being returned from call_command() but this > errno is unrelated or confusing. Maybe errno should be initialized at > the beginning of main() or beginning of call_command() to clear it > before any command is run that can return an error and where the errno > may be confusing the user otherwise. 'errno' is being set on failure to open/fopen and access() in file_exist(). thanks, Mimi
diff --git a/src/evmctl.c b/src/evmctl.c index 8bdd34817408..ca9449498321 100644 --- a/src/evmctl.c +++ b/src/evmctl.c @@ -737,6 +737,7 @@ static int cmd_sign_hash(struct command *cmd) unsigned char sig[MAX_SIGNATURE_SIZE] = "\x03"; int siglen; + errno = 0; key = imaevm_params.keyfile ? : "/etc/keys/privkey_evm.pem"; /* support reading hash (eg. output of shasum) */
Prevent "errno: No such file or directory (2)" message. Signed-off-by: Mimi Zohar <zohar@linux.ibm.com> --- src/evmctl.c | 1 + 1 file changed, 1 insertion(+)