From cb70355d8721a887a18e7e1afd6876aae26a9332 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Mon, 10 Oct 2011 22:33:50 +0000 Subject: [PATCH] Backport ossl_ssize_t type from HEAD. --- CHANGES | 5 +++++ crypto/bio/bss_bio.c | 18 +++++++++--------- crypto/cms/cms.h | 8 +++++--- crypto/cms/cms_pwri.c | 5 +++-- crypto/cms/cms_smime.c | 2 +- crypto/ui/ui.h | 2 +- e_os.h | 12 ------------ e_os2.h | 20 ++++++++++++++++++++ ms/uplink.h | 4 ++-- 9 files changed, 46 insertions(+), 30 deletions(-) diff --git a/CHANGES b/CHANGES index 488abc5f78..68dd4df746 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,11 @@ Changes between 1.0.0e and 1.0.1 [xx XXX xxxx] + *) Use type ossl_ssize_t instad of ssize_t which isn't available on + all platforms. Move ssize_t definition from e_os.h to the public + header file e_os2.h as it now appears in public header file cms.h + [Steve Henson] + *) New -sigopt option to the ca, req and x509 utilities. Additional signature parameters can be passed using this option and in particular PSS. diff --git a/crypto/bio/bss_bio.c b/crypto/bio/bss_bio.c index 76bd48e767..52ef0ebcb3 100644 --- a/crypto/bio/bss_bio.c +++ b/crypto/bio/bss_bio.c @@ -277,10 +277,10 @@ static int bio_read(BIO *bio, char *buf, int size_) */ /* WARNING: The non-copying interface is largely untested as of yet * and may contain bugs. */ -static ssize_t bio_nread0(BIO *bio, char **buf) +static ossl_ssize_t bio_nread0(BIO *bio, char **buf) { struct bio_bio_st *b, *peer_b; - ssize_t num; + ossl_ssize_t num; BIO_clear_retry_flags(bio); @@ -315,15 +315,15 @@ static ssize_t bio_nread0(BIO *bio, char **buf) return num; } -static ssize_t bio_nread(BIO *bio, char **buf, size_t num_) +static ossl_ssize_t bio_nread(BIO *bio, char **buf, size_t num_) { struct bio_bio_st *b, *peer_b; - ssize_t num, available; + ossl_ssize_t num, available; if (num_ > SSIZE_MAX) num = SSIZE_MAX; else - num = (ssize_t)num_; + num = (ossl_ssize_t)num_; available = bio_nread0(bio, buf); if (num > available) @@ -428,7 +428,7 @@ static int bio_write(BIO *bio, const char *buf, int num_) * (example usage: bio_nwrite0(), write to buffer, bio_nwrite() * or just bio_nwrite(), write to buffer) */ -static ssize_t bio_nwrite0(BIO *bio, char **buf) +static ossl_ssize_t bio_nwrite0(BIO *bio, char **buf) { struct bio_bio_st *b; size_t num; @@ -476,15 +476,15 @@ static ssize_t bio_nwrite0(BIO *bio, char **buf) return num; } -static ssize_t bio_nwrite(BIO *bio, char **buf, size_t num_) +static ossl_ssize_t bio_nwrite(BIO *bio, char **buf, size_t num_) { struct bio_bio_st *b; - ssize_t num, space; + ossl_ssize_t num, space; if (num_ > SSIZE_MAX) num = SSIZE_MAX; else - num = (ssize_t)num_; + num = (ossl_ssize_t)num_; space = bio_nwrite0(bio, buf); if (num > space) diff --git a/crypto/cms/cms.h b/crypto/cms/cms.h index 8d230219f7..c48c82863e 100644 --- a/crypto/cms/cms.h +++ b/crypto/cms/cms.h @@ -185,7 +185,7 @@ int CMS_decrypt_set1_key(CMS_ContentInfo *cms, unsigned char *key, size_t keylen, unsigned char *id, size_t idlen); int CMS_decrypt_set1_password(CMS_ContentInfo *cms, - unsigned char *pass, ssize_t passlen); + unsigned char *pass, ossl_ssize_t passlen); STACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms); int CMS_RecipientInfo_type(CMS_RecipientInfo *ri); @@ -222,11 +222,13 @@ int CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri, const unsigned char *id, size_t idlen); int CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri, - unsigned char *pass, ssize_t passlen); + unsigned char *pass, + ossl_ssize_t passlen); CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms, int iter, int wrap_nid, int pbe_nid, - unsigned char *pass, ssize_t passlen, + unsigned char *pass, + ossl_ssize_t passlen, const EVP_CIPHER *kekciph); int CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri); diff --git a/crypto/cms/cms_pwri.c b/crypto/cms/cms_pwri.c index 5fe7f494bd..b79612a12d 100644 --- a/crypto/cms/cms_pwri.c +++ b/crypto/cms/cms_pwri.c @@ -63,7 +63,7 @@ #include "asn1_locl.h" int CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri, - unsigned char *pass, ssize_t passlen) + unsigned char *pass, ossl_ssize_t passlen) { CMS_PasswordRecipientInfo *pwri; if (ri->type != CMS_RECIPINFO_PASS) @@ -82,7 +82,8 @@ int CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri, CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms, int iter, int wrap_nid, int pbe_nid, - unsigned char *pass, ssize_t passlen, + unsigned char *pass, + ossl_ssize_t passlen, const EVP_CIPHER *kekciph) { CMS_RecipientInfo *ri = NULL; diff --git a/crypto/cms/cms_smime.c b/crypto/cms/cms_smime.c index ab38a258e5..a40307605b 100644 --- a/crypto/cms/cms_smime.c +++ b/crypto/cms/cms_smime.c @@ -682,7 +682,7 @@ int CMS_decrypt_set1_key(CMS_ContentInfo *cms, } int CMS_decrypt_set1_password(CMS_ContentInfo *cms, - unsigned char *pass, ssize_t passlen) + unsigned char *pass, ossl_ssize_t passlen) { STACK_OF(CMS_RecipientInfo) *ris; CMS_RecipientInfo *ri; diff --git a/crypto/ui/ui.h b/crypto/ui/ui.h index 2b1cfa2289..bd78aa413f 100644 --- a/crypto/ui/ui.h +++ b/crypto/ui/ui.h @@ -316,7 +316,7 @@ int (*UI_method_get_writer(UI_METHOD *method))(UI*,UI_STRING*); int (*UI_method_get_flusher(UI_METHOD *method))(UI*); int (*UI_method_get_reader(UI_METHOD *method))(UI*,UI_STRING*); int (*UI_method_get_closer(UI_METHOD *method))(UI*); -char* (*UI_method_get_prompt_constructor(UI_METHOD *method))(UI*, const char*, const char*); +char * (*UI_method_get_prompt_constructor(UI_METHOD *method))(UI*, const char*, const char*); /* The following functions are helpers for method writers to access relevant data from a UI_STRING. */ diff --git a/e_os.h b/e_os.h index 5ceeeeb950..79c1392573 100644 --- a/e_os.h +++ b/e_os.h @@ -99,7 +99,6 @@ extern "C" { # ifndef MAC_OS_GUSI_SOURCE # define MAC_OS_pre_X # define NO_SYS_TYPES_H - typedef long ssize_t; # endif # define NO_SYS_PARAM_H # define NO_CHMOD @@ -340,8 +339,6 @@ static unsigned int _strlen31(const char *str) # define OPENSSL_NO_POSIX_IO # endif -# define ssize_t long - # if defined (__BORLANDC__) # define _setmode setmode # define _O_TEXT O_TEXT @@ -456,9 +453,6 @@ static unsigned int _strlen31(const char *str) * (unless when compiling with -D_POSIX_SOURCE, * which doesn't work for us) */ # endif -# if defined(NeXT) || defined(OPENSSL_SYS_NEWS4) || defined(OPENSSL_SYS_SUNOS) -# define ssize_t int /* ditto */ -# endif # ifdef OPENSSL_SYS_NEWS4 /* setvbuf is missing on mips-sony-bsd */ # define setvbuf(a, b, c, d) setbuffer((a), (b), (d)) typedef unsigned long clock_t; @@ -637,12 +631,6 @@ static unsigned int _strlen31(const char *str) #endif -#if defined(__ultrix) -# ifndef ssize_t -# define ssize_t int -# endif -#endif - #if defined(sun) && !defined(__svr4__) && !defined(__SVR4) /* include headers first, so our defines don't break it */ #include diff --git a/e_os2.h b/e_os2.h index 4c785c62cf..5106f44f51 100644 --- a/e_os2.h +++ b/e_os2.h @@ -283,6 +283,26 @@ extern "C" { # define OPENSSL_GLOBAL_REF(name) _shadow_##name #endif +#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && macintosh==1 && !defined(MAC_OS_GUSI_SOURCE) +# define ossl_ssize_t long +#endif + +#ifdef OPENSSL_SYS_MSDOS +# define ossl_ssize_t long +#endif + +#if defined(NeXT) || defined(OPENSSL_SYS_NEWS4) || defined(OPENSSL_SYS_SUNOS) +# define ssize_t int +#endif + +#if defined(__ultrix) && !defined(ssize_t) +# define ossl_ssize_t int +#endif + +#ifndef ossl_ssize_t +# define ossl_ssize_t ssize_t +#endif + #ifdef __cplusplus } #endif diff --git a/ms/uplink.h b/ms/uplink.h index a4a67d3c14..4881ba7d42 100644 --- a/ms/uplink.h +++ b/ms/uplink.h @@ -23,7 +23,7 @@ extern void *OPENSSL_UplinkTable[]; #define UP_fileno (*(int (*)(void *))OPENSSL_UplinkTable[APPLINK_FILENO]) #define UP_open (*(int (*)(const char *,int,...))OPENSSL_UplinkTable[APPLINK_OPEN]) -#define UP_read (*(ssize_t (*)(int,void *,size_t))OPENSSL_UplinkTable[APPLINK_READ]) -#define UP_write (*(ssize_t (*)(int,const void *,size_t))OPENSSL_UplinkTable[APPLINK_WRITE]) +#define UP_read (*(ossl_ssize_t (*)(int,void *,size_t))OPENSSL_UplinkTable[APPLINK_READ]) +#define UP_write (*(ossl_ssize_t (*)(int,const void *,size_t))OPENSSL_UplinkTable[APPLINK_WRITE]) #define UP_lseek (*(long (*)(int,long,int))OPENSSL_UplinkTable[APPLINK_LSEEK]) #define UP_close (*(int (*)(int))OPENSSL_UplinkTable[APPLINK_CLOSE]) -- 2.25.1