Diff

Differences From Artifact [941bf5cf9b]:

To Artifact [be5fbbbf72]:


  1370   1370   	unsigned char vlen_buf[2], vval_buf[8192], *vval;
  1371   1371   	unsigned char *tmpbuf;
  1372   1372   	ssize_t tlen, vlen;
  1373   1373   	ssize_t read_ret;
  1374   1374   	size_t offset_t = 0, offset_v = 0;
  1375   1375   	unsigned char tag;
  1376   1376   	size_t length;
         1377  +#ifdef HAVE_LIBZ
  1377   1378   	uLongf tmpbuflen;
  1378   1379   	int uncompress_ret;
         1380  +#endif
  1379   1381   
  1380   1382   	CACKEY_DEBUG_PRINTF("Called.");
  1381   1383   
  1382   1384   	read_ret = cackey_read_buffer(slot, tlen_buf, sizeof(tlen_buf), 1, offset_t);
  1383   1385   	if (read_ret != sizeof(tlen_buf)) {
  1384   1386   		CACKEY_DEBUG_PRINTF("Read failed, returning in failure");
  1385   1387   
................................................................................
  1478   1480   			case GSCIS_TAG_CERTIFICATE:
  1479   1481   				curr_entity = malloc(sizeof(*curr_entity));
  1480   1482   
  1481   1483   				tmpbuflen = length * 2;
  1482   1484   				tmpbuf = malloc(tmpbuflen);
  1483   1485   
  1484   1486   #ifdef HAVE_LIBZ
  1485         -				CACKEY_DEBUG_PRINTBUF("Decompressing:", vval, length);
  1486   1487   				uncompress_ret = uncompress(tmpbuf, &tmpbuflen, vval, length);
  1487   1488   				if (uncompress_ret != Z_OK) {
  1488   1489   					CACKEY_DEBUG_PRINTF("Failed to decompress, uncompress() returned %i -- resorting to direct copy", uncompress_ret);
  1489   1490   
  1490   1491   					tmpbuflen = length;
  1491   1492   					memcpy(tmpbuf, vval, length);
  1492   1493   				}
................................................................................
  2016   2017   				break;
  2017   2018   			case CKA_LABEL:
  2018   2019   				CACKEY_DEBUG_PRINTF("Requesting attribute CKA_LABEL (0x%08lx) ...", (unsigned long) curr_attr_type);
  2019   2020   
  2020   2021   				/* Determine name */
  2021   2022   				if (certificate_len >= 0) {
  2022   2023   					x509_read_ret = x509_to_subject(certificate, certificate_len, &pValue);
  2023         -					if (x509_read_ret < 0) {
  2024         -						pValue = NULL;
         2024  +					if (x509_read_ret > 0) {
         2025  +						x509_read_ret = x509_dn_to_string(pValue, x509_read_ret, (char *) ucTmpBuf, sizeof(ucTmpBuf), "CN");
         2026  +						if (x509_read_ret <= 0) {
         2027  +							x509_read_ret = x509_dn_to_string(pValue, x509_read_ret, (char *) ucTmpBuf, sizeof(ucTmpBuf), NULL);
         2028  +
         2029  +							if (x509_read_ret <= 0) {
         2030  +								pValue = NULL;
         2031  +							} else {
         2032  +								pValue = ucTmpBuf;
         2033  +								ulValueLen = x509_read_ret;
         2034  +							}
         2035  +						} else {
         2036  +							pValue = ucTmpBuf;
         2037  +							ulValueLen = x509_read_ret;
         2038  +						}
  2025   2039   					} else {
  2026         -						ulValueLen = x509_read_ret;
         2040  +						pValue = NULL;
  2027   2041   					}
  2028   2042   				}
  2029   2043   
  2030   2044   				CACKEY_DEBUG_PRINTF(" ... returning (%p/%lu)", pValue, (unsigned long) ulValueLen);
  2031   2045   
  2032   2046   				break;
  2033   2047   			case CKA_VALUE: