Re: [PATCH v2] ima-evm-utils: use tsspcrread to read the TPM 2.0 PCRs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mimi,

On Tue, Jul 23, 2019 at 02:24:53PM -0400, Mimi Zohar wrote:
> On Tue, 2019-07-23 at 19:41 +0300, Vitaly Chikunov wrote:
> > On Tue, Jul 23, 2019 at 11:53:10AM -0400, Mimi Zohar wrote:
> > > On Tue, 2019-07-23 at 12:47 -0300, Bruno E. O. Meneguele wrote:
> > > 
> > > > > @@ -1402,6 +1400,41 @@ static int tpm_pcr_read(int idx, uint8_t *pcr, int len)
> > > > >  	return result;
> > > > >  }
> > > > >  
> > > > > +#ifdef HAVE_TSSPCRREAD
> > > > > +static int tpm2_pcr_read(int idx, uint8_t *hwpcr, int len, char **errmsg)
> > > > > +{
> > > > > +	FILE *fp;
> > > > > +	char pcr[100];	/* may contain an error */
> > > > > +	char cmd[50];
> > > > > +	int ret;
> > > > > +
> > > > > +	sprintf(cmd, "tsspcrread -halg sha1 -ha %d -ns 2> /dev/null", idx);
> > > > > +	fp = popen(cmd, "r");
> > > > > +	if (!fp) {
> > > > > +		snprintf(pcr, sizeof(pcr), "popen failed: %s", strerror(errno));
> > > > > +		*errmsg = strdup("popen failed:");
> > > > 
> > > > Should it have been 
> > > > 
> > > > *errmsg = strdup(pcr);
> > > > 
> > > Yes, of course.
> > 
> > Or better to use asprintf(3).
> 
> That's even better, assuming that we want to include
> AC_USE_SYSTEM_EXTENSIONS in configure.ac?

Yes.

> Did you want to make this change as a separate patch, or should I fold
> it into this one?

Probably you, since you are first to add snprintf+strdup.

Thanks,




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux Kernel]     [Linux Kernel Hardening]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux