~ubuntu-branches/ubuntu/gutsy/openssl/gutsy-security

« back to all changes in this revision

Viewing changes to ssl/kssl.c

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2007-03-10 17:11:46 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070310171146-ekahy2avht7qdc4f
Tags: 0.9.8e-4
openssl should depend on libssl0.9.8 0.9.8e-1 since it 
uses some of the defines that changed to functions.
Other things build against libssl or libcrypto shouldn't 
have this problem since they use the old headers.
(Closes: #414283)

Show diffs side-by-side

added added

removed removed

Lines of Context:
784
784
        }
785
785
#endif  /* OPENSSL_SYS_WINDOWS || OPENSSL_SYS_WIN32 */
786
786
 
 
787
 
 
788
/* memory allocation functions for non-temporary storage
 
789
 * (e.g. stuff that gets saved into the kssl context) */
 
790
static void* kssl_calloc(size_t nmemb, size_t size)
 
791
{
 
792
        void* p;
 
793
        
 
794
        p=OPENSSL_malloc(nmemb*size);
 
795
        if (p){
 
796
                memset(p, 0, nmemb*size);
 
797
        }
 
798
        return p;
 
799
}
 
800
 
 
801
#define kssl_malloc(size) OPENSSL_malloc((size))
 
802
#define kssl_realloc(ptr, size) OPENSSL_realloc(ptr, size)
 
803
#define kssl_free(ptr) OPENSSL_free((ptr))
 
804
 
 
805
 
787
806
char
788
807
*kstring(char *string)
789
808
        {
1548
1567
KSSL_CTX        *
1549
1568
kssl_ctx_new(void)
1550
1569
        {
1551
 
        return ((KSSL_CTX *) calloc(1, sizeof(KSSL_CTX)));
 
1570
        return ((KSSL_CTX *) kssl_calloc(1, sizeof(KSSL_CTX)));
1552
1571
        }
1553
1572
 
1554
1573
 
1562
1581
 
1563
1582
        if (kssl_ctx->key)              OPENSSL_cleanse(kssl_ctx->key,
1564
1583
                                                              kssl_ctx->length);
1565
 
        if (kssl_ctx->key)              free(kssl_ctx->key);
1566
 
        if (kssl_ctx->client_princ)     free(kssl_ctx->client_princ);
1567
 
        if (kssl_ctx->service_host)     free(kssl_ctx->service_host);
1568
 
        if (kssl_ctx->service_name)     free(kssl_ctx->service_name);
1569
 
        if (kssl_ctx->keytab_file)      free(kssl_ctx->keytab_file);
 
1584
        if (kssl_ctx->key)              kssl_free(kssl_ctx->key);
 
1585
        if (kssl_ctx->client_princ)     kssl_free(kssl_ctx->client_princ);
 
1586
        if (kssl_ctx->service_host)     kssl_free(kssl_ctx->service_host);
 
1587
        if (kssl_ctx->service_name)     kssl_free(kssl_ctx->service_name);
 
1588
        if (kssl_ctx->keytab_file)      kssl_free(kssl_ctx->keytab_file);
1570
1589
 
1571
 
        free(kssl_ctx);
 
1590
        kssl_free(kssl_ctx);
1572
1591
        return (KSSL_CTX *) NULL;
1573
1592
        }
1574
1593
 
1593
1612
        case KSSL_SERVER:       princ = &kssl_ctx->service_host;        break;
1594
1613
        default:                return KSSL_CTX_ERR;                    break;
1595
1614
                }
1596
 
        if (*princ)  free(*princ);
 
1615
        if (*princ)  kssl_free(*princ);
1597
1616
 
1598
1617
        /* Add up all the entity->lengths */
1599
1618
        length = 0;
1606
1625
        /* Space for the ('@'+realm+NULL | NULL) */
1607
1626
        length += ((realm)? realm->length + 2: 1);
1608
1627
 
1609
 
        if ((*princ = calloc(1, length)) == NULL)
 
1628
        if ((*princ = kssl_calloc(1, length)) == NULL)
1610
1629
                return KSSL_CTX_ERR;
1611
1630
        else
1612
1631
                {
1649
1668
        case KSSL_KEYTAB:       string = &kssl_ctx->keytab_file;        break;
1650
1669
        default:                return KSSL_CTX_ERR;                    break;
1651
1670
                }
1652
 
        if (*string)  free(*string);
 
1671
        if (*string)  kssl_free(*string);
1653
1672
 
1654
1673
        if (!text)
1655
1674
                {
1657
1676
                return KSSL_CTX_OK;
1658
1677
                }
1659
1678
 
1660
 
        if ((*string = calloc(1, strlen(text) + 1)) == NULL)
 
1679
        if ((*string = kssl_calloc(1, strlen(text) + 1)) == NULL)
1661
1680
                return KSSL_CTX_ERR;
1662
1681
        else
1663
1682
                strcpy(*string, text);
1681
1700
        if (kssl_ctx->key)
1682
1701
                {
1683
1702
                OPENSSL_cleanse(kssl_ctx->key, kssl_ctx->length);
1684
 
                free(kssl_ctx->key);
 
1703
                kssl_free(kssl_ctx->key);
1685
1704
                }
1686
1705
 
1687
1706
        if (session)
1707
1726
                }
1708
1727
 
1709
1728
        if ((kssl_ctx->key =
1710
 
                (krb5_octet FAR *) calloc(1, kssl_ctx->length)) == NULL)
 
1729
                (krb5_octet FAR *) kssl_calloc(1, kssl_ctx->length)) == NULL)
1711
1730
                {
1712
1731
                kssl_ctx->length  = 0;
1713
1732
                return KSSL_CTX_ERR;