use bounded string ops (especially libraries)

This commit is contained in:
itojun 2003-07-14 13:05:19 +00:00
parent 96df404b38
commit 848c8ac0ef
48 changed files with 302 additions and 179 deletions

View File

@ -451,9 +451,9 @@ bad:
#else
strncpy(buf[0],X509_get_default_cert_area(),
sizeof(buf[0])-2-sizeof(CONFIG_FILE));
strcat(buf[0],"/");
strlcat(buf[0], "/", sizeof(buf[0]));
#endif
strcat(buf[0],CONFIG_FILE);
strlcat(buf[0], CONFIG_FILE, sizeof(buf[0]));
configfile=buf[0];
}
@ -951,9 +951,9 @@ bad:
strncpy(buf[0],serialfile,BSIZE-4);
#ifdef VMS
strcat(buf[0],"-new");
strlcat(buf[0], "-new", sizeof(buf[0]));
#else
strcat(buf[0],".new");
strlcat(buf[0], ".new", sizeof(buf[0]));
#endif
if (!save_serial(buf[0],serial)) goto err;
@ -961,9 +961,9 @@ bad:
strncpy(buf[1],dbfile,BSIZE-4);
#ifdef VMS
strcat(buf[1],"-new");
strlcat(buf[1], "-new", sizeof(buf[1]));
#else
strcat(buf[1],".new");
strlcat(buf[1], ".new", sizeof(buf[1]));
#endif
if (BIO_write_filename(out,buf[1]) <= 0)
@ -991,7 +991,7 @@ bad:
strncpy(buf[2],outdir,BSIZE-(j*2)-6);
#ifndef VMS
strcat(buf[2],"/");
strlcat(buf[2], "/", sizeof(buf[2]));
#endif
n=(unsigned char *)&(buf[2][strlen(buf[2])]);
@ -999,7 +999,9 @@ bad:
{
for (k=0; k<j; k++)
{
sprintf((char *)n,"%02X",(unsigned char)*(p++));
snprintf((char *)n,
sizeof(buf[2]) - (n - buf[2]),
"%02X",(unsigned char)*(p++));
n+=2;
}
}

View File

@ -391,7 +391,7 @@ bad:
{
char buf[200];
sprintf(buf,"enter %s %s password:",
snprintf(buf, sizeof(buf), "enter %s %s password:",
OBJ_nid2ln(EVP_CIPHER_nid(cipher)),
(enc)?"encryption":"decryption");
strbuf[0]='\0';

View File

@ -1011,18 +1011,18 @@ start: for (;;)
}
/* If OBJ not recognised ignore it */
if ((nid=OBJ_txt2nid(type)) == NID_undef) goto start;
sprintf(buf,"%s_default",v->name);
snprintf(buf, sizeof(buf), "%s_default", v->name);
if ((def=CONF_get_string(req_conf,dn_sect,buf)) == NULL)
def="";
sprintf(buf,"%s_value",v->name);
snprintf(buf, sizeof(buf), "%s_value", v->name);
if ((value=CONF_get_string(req_conf,dn_sect,buf)) == NULL)
value=NULL;
sprintf(buf,"%s_min",v->name);
snprintf(buf, sizeof(buf), "%s_min", v->name);
min=(int)CONF_get_number(req_conf,dn_sect,buf);
sprintf(buf,"%s_max",v->name);
snprintf(buf, sizeof(buf), "%s_max", v->name);
max=(int)CONF_get_number(req_conf,dn_sect,buf);
if (!add_DN_object(subj,v->value,def,value,nid,
@ -1056,20 +1056,20 @@ start2: for (;;)
if ((nid=OBJ_txt2nid(type)) == NID_undef)
goto start2;
sprintf(buf,"%s_default",type);
snprintf(buf, sizeof(buf), "%s_default", type);
if ((def=CONF_get_string(req_conf,attr_sect,buf))
== NULL)
def="";
sprintf(buf,"%s_value",type);
snprintf(buf, sizeof(buf),"%s_value", type);
if ((value=CONF_get_string(req_conf,attr_sect,buf))
== NULL)
value=NULL;
sprintf(buf,"%s_min",type);
snprintf(buf, sizeof(buf), "%s_min", type);
min=(int)CONF_get_number(req_conf,attr_sect,buf);
sprintf(buf,"%s_max",type);
snprintf(buf, sizeof(buf), "%s_max", type);
max=(int)CONF_get_number(req_conf,attr_sect,buf);
if (!add_attribute_object(req,

View File

@ -489,7 +489,8 @@ int MAIN(int argc, char **argv)
if (s_www_path != NULL)
{
sprintf(buf,"GET %s HTTP/1.0\r\n\r\n",s_www_path);
snprintf(buf, sizeof(buf), "GET %s HTTP/1.0\r\n\r\n",
s_www_path);
SSL_write(scon,buf,strlen(buf));
while ((i=SSL_read(scon,buf,sizeof(buf))) > 0)
bytes_read+=i;
@ -544,7 +545,8 @@ next:
if (s_www_path != NULL)
{
sprintf(buf,"GET %s HTTP/1.0\r\n\r\n",s_www_path);
snprintf(buf, sizeof(buf), "GET %s HTTP/1.0\r\n\r\n",
s_www_path);
SSL_write(scon,buf,strlen(buf));
while (SSL_read(scon,buf,sizeof(buf)) > 0)
;
@ -582,7 +584,8 @@ next:
if (s_www_path)
{
sprintf(buf,"GET %s HTTP/1.0\r\n\r\n",s_www_path);
snprintf(buf, sizeof(buf), "GET %s HTTP/1.0\r\n\r\n",
s_www_path);
SSL_write(scon,buf,strlen(buf));
while ((i=SSL_read(scon,buf,sizeof(buf))) > 0)
bytes_read+=i;

View File

@ -219,8 +219,8 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
s->data=(unsigned char *)p;
}
sprintf(p,"%04d%02d%02d%02d%02d%02dZ",ts->tm_year + 1900,
ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec);
snprintf(p, 20, "%04d%02d%02d%02d%02d%02dZ",ts->tm_year + 1900,
ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min, ts->tm_sec);
s->length=strlen(p);
s->type=V_ASN1_GENERALIZEDTIME;
#ifdef CHARSET_EBCDIC_not

View File

@ -145,14 +145,14 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
if((minsize > 0) && (nchar < minsize)) {
ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_STRING_TOO_SHORT);
sprintf(strbuf, "%ld", minsize);
snprintf(strbuf, sizeof(strbuf), "%ld", minsize);
ERR_add_error_data(2, "minsize=", strbuf);
return -1;
}
if((maxsize > 0) && (nchar > maxsize)) {
ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_STRING_TOO_LONG);
sprintf(strbuf, "%ld", maxsize);
snprintf(strbuf, sizeof(strbuf), "%ld", maxsize);
ERR_add_error_data(2, "maxsize=", strbuf);
return -1;
}

View File

@ -256,8 +256,8 @@ ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
s->data=(unsigned char *)p;
}
sprintf(p,"%02d%02d%02d%02d%02d%02dZ",ts->tm_year%100,
ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec);
snprintf(p, 20, "%02d%02d%02d%02d%02d%02dZ", ts->tm_year%100,
ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min, ts->tm_sec);
s->length=strlen(p);
s->type=V_ASN1_UTCTIME;
#ifdef CHARSET_EBCDIC_not

View File

@ -412,8 +412,8 @@ void asn1_add_error(unsigned char *address, int offset)
{
char buf1[DECIMAL_SIZE(address)+1],buf2[DECIMAL_SIZE(offset)+1];
sprintf(buf1,"%lu",(unsigned long)address);
sprintf(buf2,"%d",offset);
snprintf(buf1, sizeof(buf1), "%lu", (unsigned long)address);
snprintf(buf2, sizeof(buf2), "%d", offset);
ERR_add_error_data(4,"address=",buf1," offset=",buf2);
}

View File

@ -88,11 +88,11 @@ static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
p=str;
if ((xclass & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
sprintf(str,"priv [ %d ] ",tag);
snprintf(str, sizeof(str), "priv [ %d ] ", tag);
else if ((xclass & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC)
sprintf(str,"cont [ %d ]",tag);
snprintf(str, sizeof(str), "cont [ %d ]", tag);
else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
sprintf(str,"appl [ %d ]",tag);
snprintf(str, sizeof(str), "appl [ %d ]", tag);
else p = ASN1_tag2str(tag);
if (p2 != NULL)

View File

@ -143,9 +143,10 @@ int RSA_print(BIO *bp, RSA *x, int off)
}
if (x->d == NULL)
sprintf(str,"Modulus (%d bit):",BN_num_bits(x->n));
snprintf(str, sizeof(str), "Modulus (%d bit):",
BN_num_bits(x->n));
else
strcpy(str,"modulus:");
strlcpy(str,"modulus:", sizeof(str));
if (!print(bp,str,x->n,m,off)) goto err;
s=(x->d == NULL)?"Exponent:":"publicExponent:";
if (!print(bp,s,x->e,m,off)) goto err;

View File

@ -95,26 +95,27 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
char str[128];
ri=x->req_info;
sprintf(str,"Certificate Request:\n");
snprintf(str, sizeof(str), "Certificate Request:\n");
if (BIO_puts(bp,str) <= 0) goto err;
sprintf(str,"%4sData:\n","");
snprintf(str, sizeof(str), "%4sData:\n","");
if (BIO_puts(bp,str) <= 0) goto err;
neg=(ri->version->type == V_ASN1_NEG_INTEGER)?"-":"";
l=0;
for (i=0; i<ri->version->length; i++)
{ l<<=8; l+=ri->version->data[i]; }
sprintf(str,"%8sVersion: %s%lu (%s0x%lx)\n","",neg,l,neg,l);
snprintf(str, sizeof(str), "%8sVersion: %s%lu (%s0x%lx)\n", "", neg,
l, neg, l);
if (BIO_puts(bp,str) <= 0) goto err;
sprintf(str,"%8sSubject: ","");
snprintf(str, sizeof(str), "%8sSubject: ", "");
if (BIO_puts(bp,str) <= 0) goto err;
X509_NAME_print(bp,ri->subject,16);
sprintf(str,"\n%8sSubject Public Key Info:\n","");
snprintf(str, sizeof(str), "\n%8sSubject Public Key Info:\n", "");
if (BIO_puts(bp,str) <= 0) goto err;
i=OBJ_obj2nid(ri->pubkey->algor->algorithm);
sprintf(str,"%12sPublic Key Algorithm: %s\n","",
(i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i));
snprintf(str, sizeof(str), "%12sPublic Key Algorithm: %s\n", "",
(i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i));
if (BIO_puts(bp,str) <= 0) goto err;
pkey=X509_REQ_get_pubkey(x);
@ -141,7 +142,7 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
EVP_PKEY_free(pkey);
/* may not be */
sprintf(str,"%8sAttributes:\n","");
snprintf(str, sizeof(str), "%8sAttributes:\n", "");
if (BIO_puts(bp,str) <= 0) goto err;
sk=x->req_info->attributes;
@ -149,7 +150,7 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
{
if (!x->req_info->req_kludge)
{
sprintf(str,"%12sa0:00\n","");
snprintf(str, sizeof(str), "%12sa0:00\n", "");
if (BIO_puts(bp,str) <= 0) goto err;
}
}
@ -166,7 +167,7 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
a=sk_X509_ATTRIBUTE_value(sk,i);
if(X509_REQ_extension_nid(OBJ_obj2nid(a->object)))
continue;
sprintf(str,"%12s","");
snprintf(str, sizeof(str), "%12s", "");
if (BIO_puts(bp,str) <= 0) goto err;
if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0)
{
@ -230,8 +231,8 @@ get_next:
}
i=OBJ_obj2nid(x->sig_alg->algorithm);
sprintf(str,"%4sSignature Algorithm: %s","",
(i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i));
snprintf(str, sizeof(str), "%4sSignature Algorithm: %s", "",
(i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i));
if (BIO_puts(bp,str) <= 0) goto err;
n=x->signature->length;
@ -240,10 +241,11 @@ get_next:
{
if ((i%18) == 0)
{
sprintf(str,"\n%8s","");
snprintf(str, sizeof(str), "\n%8s", "");
if (BIO_puts(bp,str) <= 0) goto err;
}
sprintf(str,"%02x%s",(unsigned char)s[i],((i+1) == n)?"":":");
snprintf(str, sizeof(str), "%02x%s", (unsigned char)s[i],
((i + 1) == n) ? "" : ":");
if (BIO_puts(bp,str) <= 0) goto err;
}
if (BIO_puts(bp,"\n") <= 0) goto err;

View File

@ -104,38 +104,40 @@ int BIO_dump_indent(BIO *bio, const char *s, int len, int indent)
for(i=0;i<rows;i++)
{
buf[0]='\0'; /* start with empty string */
strcpy(buf,str);
sprintf(tmp,"%04x - ",i*dump_width);
strcat(buf,tmp);
strlcpy(buf, str, sizeof(buf));
snprintf(tmp, sizeof(tmp), "%04x - ", i * dump_width);
strlcat(buf, tmp, sizeof(tmp));
for(j=0;j<dump_width;j++)
{
if (((i*dump_width)+j)>=len)
{
strcat(buf," ");
strlcat(buf, " ", sizeof(buf));
}
else
{
ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
sprintf(tmp,"%02x%c",ch,j==7?'-':' ');
strcat(buf,tmp);
snprintf(tmp, sizeof(tmp), "%02x%c", ch,
j == 7 ? '-' : ' ');
strlcat(buf, tmp, sizeof(buf));
}
}
strcat(buf," ");
strlcat(buf, " ", sizeof(buf));
for(j=0;j<dump_width;j++)
{
if (((i*dump_width)+j)>=len)
break;
ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
#ifndef CHARSET_EBCDIC
sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.');
snprintf(tmp, sizeof(tmp), "%c",
((ch >= ' ') && (ch <= '~')) ? ch : '.');
#else
sprintf(tmp,"%c",((ch>=os_toascii[' '])&&(ch<=os_toascii['~']))
? os_toebcdic[ch]
: '.');
snprintf(tmp, sizeof(tmp), "%c",
((ch >= os_toascii[' ']) && (ch <= os_toascii['~']))
? os_toebcdic[ch] : '.');
#endif
strcat(buf,tmp);
strlcat(buf, tmp, sizeof(buf));
}
strcat(buf,"\n");
strlcat(buf, "\n", sizeof(buf));
/* if this is the last call then update the ddt_dump thing so that
* we will move the selection point in the debug window
*/
@ -144,7 +146,8 @@ int BIO_dump_indent(BIO *bio, const char *s, int len, int indent)
#ifdef TRUNCATE
if (trunc > 0)
{
sprintf(buf,"%s%04x - <SPACES/NULS>\n",str,len+trunc);
snprintf(buf, sizeof(buf), "%s%04x - <SPACES/NULS>\n", str,
len + trunc);
ret+=BIO_write(bio,(char *)buf,strlen(buf));
}
#endif

View File

@ -74,51 +74,64 @@ long MS_CALLBACK BIO_debug_callback(BIO *bio, int cmd, const char *argp,
if (BIO_CB_RETURN & cmd)
r=ret;
sprintf(buf,"BIO[%08lX]:",(unsigned long)bio);
snprintf(buf, sizeof(buf), "BIO[%08lX]:", (unsigned long)bio);
p= &(buf[14]);
switch (cmd)
{
case BIO_CB_FREE:
sprintf(p,"Free - %s\n",bio->method->name);
snprintf(p, sizeof(buf) - (p - buf), "Free - %s\n",
bio->method->name);
break;
case BIO_CB_READ:
if (bio->method->type & BIO_TYPE_DESCRIPTOR)
sprintf(p,"read(%d,%d) - %s fd=%d\n",bio->num,argi,bio->method->name,bio->num);
snprintf(p, sizeof(buf) - (p - buf),
"read(%d,%d) - %s fd=%d\n", bio->num, argi,
bio->method->name,bio->num);
else
sprintf(p,"read(%d,%d) - %s\n",bio->num,argi,bio->method->name);
snprintf(p, sizeof(buf) - (p - buf),
"read(%d,%d) - %s\n", bio->num, argi,
bio->method->name);
break;
case BIO_CB_WRITE:
if (bio->method->type & BIO_TYPE_DESCRIPTOR)
sprintf(p,"write(%d,%d) - %s fd=%d\n",bio->num,argi,bio->method->name,bio->num);
snprintf(p, sizeof(buf) - (p - buf),
"write(%d,%d) - %s fd=%d\n", bio->num, argi,
bio->method->name,bio->num);
else
sprintf(p,"write(%d,%d) - %s\n",bio->num,argi,bio->method->name);
snprintf(p, sizeof(buf) - (p - buf),
"write(%d,%d) - %s\n", bio->num, argi,
bio->method->name);
break;
case BIO_CB_PUTS:
sprintf(p,"puts() - %s\n",bio->method->name);
snprintf(p, sizeof(buf) - (p - buf), "puts() - %s\n",
bio->method->name);
break;
case BIO_CB_GETS:
sprintf(p,"gets(%d) - %s\n",argi,bio->method->name);
snprintf(p, sizeof(buf) - (p - buf), "gets(%d) - %s\n",
argi, bio->method->name);
break;
case BIO_CB_CTRL:
sprintf(p,"ctrl(%d) - %s\n",argi,bio->method->name);
snprintf(p, sizeof(buf) - (p - buf), "ctrl(%d) - %s\n",
argi, bio->method->name);
break;
case BIO_CB_RETURN|BIO_CB_READ:
sprintf(p,"read return %ld\n",ret);
snprintf(p, sizeof(buf) - (p - buf), "read return %ld\n", ret);
break;
case BIO_CB_RETURN|BIO_CB_WRITE:
sprintf(p,"write return %ld\n",ret);
snprintf(p, sizeof(buf) - (p - buf), "write return %ld\n", ret);
break;
case BIO_CB_RETURN|BIO_CB_GETS:
sprintf(p,"gets return %ld\n",ret);
snprintf(p, sizeof(buf) - (p - buf), "gets return %ld\n", ret);
break;
case BIO_CB_RETURN|BIO_CB_PUTS:
sprintf(p,"puts return %ld\n",ret);
snprintf(p, sizeof(buf) - (p - buf), "puts return %ld\n", ret);
break;
case BIO_CB_RETURN|BIO_CB_CTRL:
sprintf(p,"ctrl return %ld\n",ret);
snprintf(p, sizeof(buf) - (p - buf), "ctrl return %ld\n", ret);
break;
default:
sprintf(p,"bio callback - unknown type (%d)\n",cmd);
snprintf(p, sizeof(buf) - (p - buf),
"bio callback - unknown type (%d)\n", cmd);
break;
}

View File

@ -521,8 +521,8 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
char buf[16];
char *p = ptr;
sprintf(buf,"%d.%d.%d.%d",
p[0],p[1],p[2],p[3]);
snprintf(buf, sizeof(buf), "%d.%d.%d.%d",
p[0], p[1], p[2], p[3]);
if (data->param_hostname != NULL)
OPENSSL_free(data->param_hostname);
data->param_hostname=BUF_strdup(buf);
@ -532,7 +532,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
{
char buf[16];
sprintf(buf,"%d",*(int *)ptr);
snprintf(buf, sizeof(buf), "%d", *(int *)ptr);
if (data->param_port != NULL)
OPENSSL_free(data->param_port);
data->param_port=BUF_strdup(buf);

View File

@ -218,15 +218,15 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
if (num & BIO_FP_APPEND)
{
if (num & BIO_FP_READ)
strcpy(p,"a+");
else strcpy(p,"a");
strlcpy(p, "a+", sizeof(p));
else strlcpy(p, "a", sizeof(p));
}
else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE))
strcpy(p,"r+");
strlcpy(p, "r+", sizeof(p));
else if (num & BIO_FP_WRITE)
strcpy(p,"w");
strlcpy(p, "w", sizeof(p));
else if (num & BIO_FP_READ)
strcpy(p,"r");
strlcpy(p, "r", sizeof(p));
else
{
BIOerr(BIO_F_FILE_CTRL,BIO_R_BAD_FOPEN_MODE);
@ -235,9 +235,9 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
}
#if defined(MSDOS) || defined(WINDOWS)
if (!(num & BIO_FP_TEXT))
strcat(p,"b");
strlcat(p, "b", sizeof(p));
else
strcat(p,"t");
strlcat(p, "t", sizeof(p));
#endif
fp=fopen(ptr,p);
if (fp == NULL)

View File

@ -297,7 +297,7 @@ static void xsyslog(BIO *bp, int priority, const char *string)
break;
}
sprintf(pidbuf, "[%d] ", pid);
snprintf(pidbuf, sizeof(pidbuf), "[%d] ", pid);
lpszStrings[0] = pidbuf;
lpszStrings[1] = string;

View File

@ -145,11 +145,11 @@ char *BN_options(void)
{
init++;
#ifdef BN_LLONG
sprintf(data,"bn(%d,%d)",(int)sizeof(BN_ULLONG)*8,
(int)sizeof(BN_ULONG)*8);
snprintf(data, sizeof(data), "bn(%d,%d)",
(int)sizeof(BN_ULLONG) * 8, (int)sizeof(BN_ULONG) * 8);
#else
sprintf(data,"bn(%d,%d)",(int)sizeof(BN_ULONG)*8,
(int)sizeof(BN_ULONG)*8);
snprintf(data, sizeof(data), "bn(%d,%d)",
(int)sizeof(BN_ULONG) * 8, (int)sizeof(BN_ULONG) * 8);
#endif
}
return(data);

View File

@ -139,12 +139,12 @@ char *BN_bn2dec(const BIGNUM *a)
/* We now have a series of blocks, BN_DEC_NUM chars
* in length, where the last one needs truncation.
* The blocks need to be reversed in order. */
sprintf(p,BN_DEC_FMT1,*lp);
snprintf(p, sizeof(buf) - (p - buf), BN_DEC_FMT1, *lp);
while (*p) p++;
while (lp != bn_data)
{
lp--;
sprintf(p,BN_DEC_FMT2,*lp);
snprintf(p, sizeof(buf) - (p - buf), BN_DEC_FMT2, *lp);
while (*p) p++;
}
}

View File

@ -206,7 +206,7 @@ static int def_load(CONF *conf, BIO *in, long *line)
CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_MALLOC_FAILURE);
goto err;
}
strcpy(section,"default");
strlcpy(section, "default", 10);
if (_CONF_new_data(conf) == 0)
{
@ -354,7 +354,7 @@ again:
goto err;
}
if (psection == NULL) psection=section;
v->name=(char *)OPENSSL_malloc(strlen(pname)+1);
v->name = BUF_strdup(pname);
v->value=NULL;
if (v->name == NULL)
{
@ -362,7 +362,6 @@ again:
ERR_R_MALLOC_FAILURE);
goto err;
}
strcpy(v->name,pname);
if (!str_copy(conf,psection,&(v->value),start)) goto err;
if (strcmp(psection,section) != 0)
@ -417,7 +416,7 @@ err:
if (buff != NULL) BUF_MEM_free(buff);
if (section != NULL) OPENSSL_free(section);
if (line != NULL) *line=eline;
sprintf(btmp,"%ld",eline);
snprintf(btmp, sizeof(btmp), "%ld", eline);
ERR_add_error_data(2,"line ",btmp);
if ((h != conf->data) && (conf->data != NULL)) CONF_free(conf->data);
if (v != NULL)

View File

@ -72,7 +72,7 @@ const char *SSLeay_version(int t)
#ifdef DATE
static char buf[sizeof(DATE)+11];
sprintf(buf,"built on: %s",DATE);
snprintf(buf, sizeof(buf), "built on: %s", DATE);
return(buf);
#else
return("built on: date not available");
@ -83,7 +83,7 @@ const char *SSLeay_version(int t)
#ifdef CFLAGS
static char buf[sizeof(CFLAGS)+11];
sprintf(buf,"compiler: %s",CFLAGS);
snprintf(buf, sizeof(buf), "compiler: %s", CFLAGS);
return(buf);
#else
return("compiler: information not available");
@ -94,7 +94,7 @@ const char *SSLeay_version(int t)
#ifdef PLATFORM
static char buf[sizeof(PLATFORM)+11];
sprintf(buf,"platform: %s", PLATFORM);
snprintf(buf, sizeof(buf), "platform: %s", PLATFORM);
return(buf);
#else
return("platform: information not available");

View File

@ -96,7 +96,8 @@ const char *des_options(void)
size="int";
else
size="long";
sprintf(buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,size);
snprintf(buf, sizeof(buf), "des(%s,%s,%s,%s)", ptr, risc,
unroll, size);
init=0;
}
return(buf);

View File

@ -157,7 +157,7 @@ int main(int argc, char *argv[])
BIO_puts(out,"key1 =");
for (i=0; i<aout; i++)
{
sprintf(buf,"%02X",abuf[i]);
snprintf(buf, sizeof(buf), "%02X", abuf[i]);
BIO_puts(out,buf);
}
BIO_puts(out,"\n");
@ -169,7 +169,7 @@ int main(int argc, char *argv[])
BIO_puts(out,"key2 =");
for (i=0; i<bout; i++)
{
sprintf(buf,"%02X",bbuf[i]);
snprintf(buf, sizeof(buf), "%02X", bbuf[i]);
BIO_puts(out,buf);
}
BIO_puts(out,"\n");

View File

@ -128,7 +128,8 @@ static int dl_load(DSO *dso, const char *filename)
(len + 3 < DSO_MAX_TRANSLATED_SIZE) &&
(strstr(filename, "/") == NULL))
{
sprintf(translated, "lib%s%s", filename, extension);
snprintf(translated, sizeof(translated), "lib%s%s", filename,
extension);
ptr = shl_load(translated, BIND_IMMEDIATE, NULL);
}
else

View File

@ -145,7 +145,7 @@ static int dlfcn_load(DSO *dso, const char *filename)
(len + 6 < DSO_MAX_TRANSLATED_SIZE) &&
(strstr(filename, "/") == NULL))
{
sprintf(translated, "lib%s.so", filename);
snprintf(translated, sizeof(translated), "lib%s.so", filename);
ptr = dlopen(translated, DLOPEN_FLAG);
}
else

View File

@ -127,7 +127,7 @@ static int win32_load(DSO *dso, const char *filename)
(strstr(filename, "\\") == NULL) &&
(strstr(filename, ":") == NULL))
{
sprintf(translated, "%s.dll", filename);
snprintf(translated, sizeof(translated), "%s.dll", filename);
h = LoadLibrary(translated);
}
else

View File

@ -789,7 +789,7 @@ void ERR_add_error_data(int num, ...)
else
str=p;
}
strcat(str,a);
strlcat(str, a, s + 1);
}
}
ERR_set_error_data(str,ERR_TXT_MALLOCED|ERR_TXT_STRING);

View File

@ -96,8 +96,8 @@ void ERR_print_errors(BIO *bp)
while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0)
{
ERR_error_string_n(l, buf, sizeof buf);
sprintf(buf2,"%lu:%s:%s:%d:",es,buf,
file,line);
snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:", es, buf,
file, line);
BIO_write(bp,buf2,strlen(buf2));
if (flags & ERR_TXT_STRING)
BIO_write(bp,data,strlen(data));

View File

@ -87,8 +87,10 @@ int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
if (i == -1) {
char obj_tmp[80];
EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_UNKNOWN_PBE_ALGORITHM);
if (!pbe_obj) strcpy (obj_tmp, "NULL");
else i2t_ASN1_OBJECT(obj_tmp, 80, pbe_obj);
if (!pbe_obj)
strlcpy(obj_tmp, "NULL", sizeof(obj_tmp));
else
i2t_ASN1_OBJECT(obj_tmp, 80, pbe_obj);
ERR_add_error_data(2, "TYPE=", obj_tmp);
return 0;
}

View File

@ -206,8 +206,10 @@ EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8)
#endif
default:
EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM);
if (!a->algorithm) strcpy (obj_tmp, "NULL");
else i2t_ASN1_OBJECT(obj_tmp, 80, a->algorithm);
if (!a->algorithm)
strlcpy(obj_tmp, "NULL", sizeof(obj_tmp));
else
i2t_ASN1_OBJECT(obj_tmp, 80, a->algorithm);
ERR_add_error_data(2, "TYPE=", obj_tmp);
EVP_PKEY_free (pkey);
return NULL;

View File

@ -153,7 +153,7 @@ static char *pt(unsigned char *md)
static char buf[80];
for (i=0; i<MD5_DIGEST_LENGTH; i++)
sprintf(&(buf[i*2]),"%02x",md[i]);
snprintf(&(buf[i * 2]), sizeof(buf) - i * 2, "%02x",md[i]);
return(buf);
}
#endif

View File

@ -181,46 +181,64 @@ void lh_stats_bio(LHASH *lh, BIO *out)
{
char buf[128];
sprintf(buf,"num_items = %lu\n",lh->num_items);
snprintf(buf, sizeof(buf), "num_items = %lu\n",
lh->num_items);
BIO_puts(out,buf);
sprintf(buf,"num_nodes = %u\n",lh->num_nodes);
snprintf(buf, sizeof(buf), "num_nodes = %u\n",
lh->num_nodes);
BIO_puts(out,buf);
sprintf(buf,"num_alloc_nodes = %u\n",lh->num_alloc_nodes);
snprintf(buf, sizeof(buf), "num_alloc_nodes = %u\n",
lh->num_alloc_nodes);
BIO_puts(out,buf);
sprintf(buf,"num_expands = %lu\n",lh->num_expands);
snprintf(buf, sizeof(buf), "num_expands = %lu\n",
lh->num_expands);
BIO_puts(out,buf);
sprintf(buf,"num_expand_reallocs = %lu\n",lh->num_expand_reallocs);
snprintf(buf, sizeof(buf), "num_expand_reallocs = %lu\n",
lh->num_expand_reallocs);
BIO_puts(out,buf);
sprintf(buf,"num_contracts = %lu\n",lh->num_contracts);
snprintf(buf, sizeof(buf), "num_contracts = %lu\n",
lh->num_contracts);
BIO_puts(out,buf);
sprintf(buf,"num_contract_reallocs = %lu\n",lh->num_contract_reallocs);
snprintf(buf, sizeof(buf), "num_contract_reallocs = %lu\n",
lh->num_contract_reallocs);
BIO_puts(out,buf);
sprintf(buf,"num_hash_calls = %lu\n",lh->num_hash_calls);
snprintf(buf, sizeof(buf), "num_hash_calls = %lu\n",
lh->num_hash_calls);
BIO_puts(out,buf);
sprintf(buf,"num_comp_calls = %lu\n",lh->num_comp_calls);
snprintf(buf, sizeof(buf), "num_comp_calls = %lu\n",
lh->num_comp_calls);
BIO_puts(out,buf);
sprintf(buf,"num_insert = %lu\n",lh->num_insert);
snprintf(buf, sizeof(buf), "num_insert = %lu\n",
lh->num_insert);
BIO_puts(out,buf);
sprintf(buf,"num_replace = %lu\n",lh->num_replace);
snprintf(buf, sizeof(buf), "num_replace = %lu\n",
lh->num_replace);
BIO_puts(out,buf);
sprintf(buf,"num_delete = %lu\n",lh->num_delete);
snprintf(buf, sizeof(buf), "num_delete = %lu\n",
lh->num_delete);
BIO_puts(out,buf);
sprintf(buf,"num_no_delete = %lu\n",lh->num_no_delete);
snprintf(buf, sizeof(buf), "num_no_delete = %lu\n",
lh->num_no_delete);
BIO_puts(out,buf);
sprintf(buf,"num_retrieve = %lu\n",lh->num_retrieve);
snprintf(buf, sizeof(buf), "num_retrieve = %lu\n",
lh->num_retrieve);
BIO_puts(out,buf);
sprintf(buf,"num_retrieve_miss = %lu\n",lh->num_retrieve_miss);
snprintf(buf, sizeof(buf), "num_retrieve_miss = %lu\n",
lh->num_retrieve_miss);
BIO_puts(out,buf);
sprintf(buf,"num_hash_comps = %lu\n",lh->num_hash_comps);
snprintf(buf, sizeof(buf), "num_hash_comps = %lu\n",
lh->num_hash_comps);
BIO_puts(out,buf);
#ifdef DEBUG
sprintf(buf,"p = %u\n",lh->p);
snprintf(buf, sizeof(buf), "p = %u\n", lh->p);
BIO_puts(out,buf);
sprintf(buf,"pmax = %u\n",lh->pmax);
snprintf(buf, sizeof(buf), "pmax = %u\n", lh->pmax);
BIO_puts(out,buf);
sprintf(buf,"up_load = %lu\n",lh->up_load);
snprintf(buf, sizeof(buf), "up_load = %lu\n",
lh->up_load);
BIO_puts(out,buf);
sprintf(buf,"down_load = %lu\n",lh->down_load);
snprintf(buf, sizeof(buf), "down_load = %lu\n",
lh->down_load);
BIO_puts(out,buf);
#endif
}
@ -235,7 +253,7 @@ void lh_node_stats_bio(LHASH *lh, BIO *out)
{
for (n=lh->b[i],num=0; n != NULL; n=n->next)
num++;
sprintf(buf,"node %6u -> %3u\n",i,num);
snprintf(buf, sizeof(buf), "node %6u -> %3u\n", i, num);
BIO_puts(out,buf);
}
}
@ -258,16 +276,16 @@ void lh_node_usage_stats_bio(LHASH *lh, BIO *out)
total+=num;
}
}
sprintf(buf,"%lu nodes used out of %u\n",n_used,lh->num_nodes);
snprintf(buf, sizeof(buf), "%lu nodes used out of %u\n", n_used,
lh->num_nodes);
BIO_puts(out,buf);
sprintf(buf,"%lu items\n",total);
snprintf(buf, sizeof(buf), "%lu items\n", total);
BIO_puts(out,buf);
if (n_used == 0) return;
sprintf(buf,"load %d.%02d actual load %d.%02d\n",
(int)(total/lh->num_nodes),
(int)((total%lh->num_nodes)*100/lh->num_nodes),
(int)(total/n_used),
(int)((total%n_used)*100/n_used));
snprintf(buf, sizeof(buf), "load %d.%02d actual load %d.%02d\n",
(int)(total/lh->num_nodes),
(int)((total%lh->num_nodes)*100/lh->num_nodes),
(int)(total/n_used), (int)((total%n_used)*100/n_used));
BIO_puts(out,buf);
}

View File

@ -129,7 +129,7 @@ static char *pt(unsigned char *md)
static char buf[80];
for (i=0; i<MD2_DIGEST_LENGTH; i++)
sprintf(&(buf[i*2]),"%02x",md[i]);
snprintf(&(buf[i * 2]), sizeof(buf) - i * 2, "%02x", md[i]);
return(buf);
}
#endif

View File

@ -125,7 +125,7 @@ static char *pt(unsigned char *md)
static char buf[80];
for (i=0; i<MD4_DIGEST_LENGTH; i++)
sprintf(&(buf[i*2]),"%02x",md[i]);
snprintf(&(buf[i * 2]), sizeof(buf) - i * 2, "%02x", md[i]);
return(buf);
}
#endif

View File

@ -125,7 +125,7 @@ static char *pt(unsigned char *md)
static char buf[80];
for (i=0; i<MD5_DIGEST_LENGTH; i++)
sprintf(&(buf[i*2]),"%02x",md[i]);
snprintf(&(buf[i * 2]), sizeof(buf) - i * 2, "%02x", md[i]);
return(buf);
}
#endif

View File

@ -586,22 +586,23 @@ static void print_leak(MEM *m, MEM_LEAK *l)
{
lcl = localtime(&m->time);
sprintf(bufp, "[%02d:%02d:%02d] ",
snprintf(bufp, sizeof(buf) - (bufp - buf), "[%02d:%02d:%02d] ",
lcl->tm_hour,lcl->tm_min,lcl->tm_sec);
bufp += strlen(bufp);
}
sprintf(bufp, "%5lu file=%s, line=%d, ",
snprintf(bufp, sizeof(buf) - (bufp - buf), "%5lu file=%s, line=%d, ",
m->order,m->file,m->line);
bufp += strlen(bufp);
if (options & V_CRYPTO_MDEBUG_THREAD)
{
sprintf(bufp, "thread=%lu, ", m->thread);
snprintf(bufp, sizeof(buf) - (bufp - buf), "thread=%lu, ",
m->thread);
bufp += strlen(bufp);
}
sprintf(bufp, "number=%d, address=%08lX\n",
snprintf(bufp, sizeof(buf) - (bufp - buf), "number=%d, address=%08lX\n",
m->num,(unsigned long)m->addr);
bufp += strlen(bufp);
@ -623,7 +624,7 @@ static void print_leak(MEM *m, MEM_LEAK *l)
ami_cnt++;
memset(buf,'>',ami_cnt);
sprintf(buf + ami_cnt,
snprintf(buf + ami_cnt, sizeof(buf) - ami_cnt,
" thread=%lu, file=%s, line=%d, info=\"",
amip->thread, amip->file, amip->line);
buf_len=strlen(buf);
@ -635,10 +636,11 @@ static void print_leak(MEM *m, MEM_LEAK *l)
}
else
{
strcpy(buf + buf_len, amip->info);
strlcpy(buf + buf_len, amip->info,
sizeof(buf) - buf_len);
buf_len = strlen(buf);
}
sprintf(buf + buf_len, "\"\n");
snprintf(buf + buf_len, sizeof(buf) - buf_len, "\"\n");
BIO_puts(l->bio,buf);
@ -672,7 +674,7 @@ void CRYPTO_mem_leaks(BIO *b)
lh_doall_arg(mh,(void (*)())print_leak,(char *)&ml);
if (ml.chunks != 0)
{
sprintf(buf,"%ld bytes leaked in %d chunks\n",
snprintf(buf, sizeof(buf), "%ld bytes leaked in %d chunks\n",
ml.bytes,ml.chunks);
BIO_puts(b,buf);
}

View File

@ -454,7 +454,7 @@ int OBJ_obj2txt(char *buf, int buf_len, ASN1_OBJECT *a, int no_name)
if (i > 2) i=2;
l-=(long)(i*40);
sprintf(tbuf,"%d.%lu",i,l);
snprintf(tbuf, sizeof(tbuf), "%d.%lu", i, l);
i=strlen(tbuf);
strncpy(buf,tbuf,buf_len);
buf_len-=i;
@ -465,7 +465,7 @@ int OBJ_obj2txt(char *buf, int buf_len, ASN1_OBJECT *a, int no_name)
for (; idx<len; idx++) {
l|=p[idx]&0x7f;
if (!(p[idx] & 0x80)) {
sprintf(tbuf,".%lu",l);
snprintf(tbuf, sizeof(tbuf), ".%lu", l);
i=strlen(tbuf);
if (buf_len > 0)
strncpy(buf,tbuf,buf_len);

View File

@ -128,7 +128,7 @@ char * PKCS12_decrypt_d2i (X509_ALGOR *algor, char * (*d2i)(),
char fname[30];
static int fnm = 1;
sprintf(fname, "DER%d", fnm++);
snprintf(fname, sizeof(fname), "DER%d", fnm++);
op = fopen(fname, "wb");
fwrite (p, 1, outlen, op);
fclose(op);

View File

@ -215,7 +215,7 @@ int bio_ber_get_header(BIO *bio, BIO_BER_CTX *ctx)
if ((ctx->tag >= 0) && (ctx->tag != tag))
{
BIOerr(BIO_F_BIO_BER_GET_HEADER,BIO_R_TAG_MISMATCH);
sprintf(buf,"tag=%d, got %d",ctx->tag,tag);
snprintf(buf, sizeof(buf), "tag=%d, got %d", ctx->tag, tag);
ERR_add_error_data(1,buf);
return(-1);
}

View File

@ -104,7 +104,7 @@ int RAND_egd(const char *path)
addr.sun_family = AF_UNIX;
if (strlen(path) > sizeof(addr.sun_path))
return (-1);
strcpy(addr.sun_path,path);
strlcpy(addr.sun_path, path, sizeof(addr.sun_path));
len = offsetof(struct sockaddr_un, sun_path) + strlen(path);
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd == -1) return (-1);
@ -136,7 +136,7 @@ int RAND_egd_bytes(const char *path,int bytes)
addr.sun_family = AF_UNIX;
if (strlen(path) > sizeof(addr.sun_path))
return (-1);
strcpy(addr.sun_path,path);
strlcpy(addr.sun_path, path, sizeof(addr.sun_path));
len = offsetof(struct sockaddr_un, sun_path) + strlen(path);
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd == -1) return (-1);

View File

@ -134,7 +134,7 @@ static char *pt(unsigned char *md)
static char buf[80];
for (i=0; i<RIPEMD160_DIGEST_LENGTH; i++)
sprintf(&(buf[i*2]),"%02x",md[i]);
snprintf(&(buf[i * 2]), sizeof(buf) - i * 2, "%02x", md[i]);
return(buf);
}
#endif

View File

@ -162,7 +162,7 @@ static char *pt(unsigned char *md)
static char buf[80];
for (i=0; i<SHA_DIGEST_LENGTH; i++)
sprintf(&(buf[i*2]),"%02x",md[i]);
snprintf(&(buf[i * 2]), sizeof(buf) - i * 2, "%02x", md[i]);
return(buf);
}
#endif

View File

@ -162,7 +162,7 @@ static char *pt(unsigned char *md)
static char buf[80];
for (i=0; i<SHA_DIGEST_LENGTH; i++)
sprintf(&(buf[i*2]),"%02x",md[i]);
snprintf(&(buf[i * 2]), sizeof(buf) - i * 2, "%02x", md[i]);
return(buf);
}
#endif

View File

@ -909,7 +909,7 @@ void thread_setup(void)
int i;
char filename[20];
strcpy(filename,"/tmp/mttest.XXXXXX");
strlcpy(filename, sizeof(filename), "/tmp/mttest.XXXXXX");
mktemp(filename);
usconfig(CONF_STHREADIOOFF);
@ -938,7 +938,7 @@ void thread_cleanup(void)
{
char buf[10];
sprintf(buf,"%2d:",i);
snprintf(buf, sizeof(buf), "%2d:", i);
usdumpsema(lock_cs[i],stdout,buf);
usfreesema(lock_cs[i],arena);
}

View File

@ -257,7 +257,7 @@ void CRYPTO_thread_setup(void)
int i;
char filename[20];
strcpy(filename,"/tmp/mttest.XXXXXX");
strlcpy(filename, "/tmp/mttest.XXXXXX", sizeof(filename));
mktemp(filename);
usconfig(CONF_STHREADIOOFF);
@ -286,7 +286,7 @@ void CRYPTO_thread_cleanup(void)
{
char buf[10];
sprintf(buf,"%2d:",i);
snprintf(buf, sizeof(buf), "%2d:", i);
usdumpsema(lock_cs[i],stdout,buf);
usfreesema(lock_cs[i],arena);
}

View File

@ -142,7 +142,7 @@ const char *X509_verify_cert_error_string(long n)
return("key usage does not include certificate signing");
default:
sprintf(buf,"error number %ld",n);
snprintf(buf, sizeof(buf), "error number %ld", n);
return(buf);
}
}

View File

@ -142,7 +142,8 @@ STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method,
X509V3_add_value("IP Address","<invalid>", &ret);
break;
}
sprintf(oline, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
snprintf(oline, sizeof(oline), "%d.%d.%d.%d",
p[0], p[1], p[2], p[3]);
X509V3_add_value("IP Address",oline, &ret);
break;

View File

@ -88,21 +88,23 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method
int i;
char objtmp[80], *ntmp;
CONF_VALUE *vtmp;
size_t l;
for(i = 0; i < sk_ACCESS_DESCRIPTION_num(ainfo); i++) {
desc = sk_ACCESS_DESCRIPTION_value(ainfo, i);
ret = i2v_GENERAL_NAME(method, desc->location, ret);
if(!ret) break;
vtmp = sk_CONF_VALUE_value(ret, i);
i2t_ASN1_OBJECT(objtmp, 80, desc->method);
ntmp = OPENSSL_malloc(strlen(objtmp) + strlen(vtmp->name) + 5);
ntmp = OPENSSL_malloc(l = strlen(objtmp) +
strlen(vtmp->name) + 5);
if(!ntmp) {
X509V3err(X509V3_F_I2V_AUTHORITY_INFO_ACCESS,
ERR_R_MALLOC_FAILURE);
return NULL;
}
strcpy(ntmp, objtmp);
strcat(ntmp, " - ");
strcat(ntmp, vtmp->name);
strlcpy(ntmp, objtmp, l);
strlcat(ntmp, " - ", l);
strlcat(ntmp, vtmp->name, l);
OPENSSL_free(vtmp->name);
vtmp->name = ntmp;

View File

@ -37,18 +37,89 @@ NO_SSL3
NO_STACK
NO_STDIO
NO_X509
OPENSSL_NO_AES
OPENSSL_NO_BF
OPENSSL_NO_BIO
OPENSSL_NO_CAST
OPENSSL_NO_COMP
OPENSSL_NO_DES
OPENSSL_NO_DH
OPENSSL_NO_DSA
OPENSSL_NO_ENGINE
OPENSSL_NO_FP_API
OPENSSL_NO_IDEA
OPENSSL_NO_LOCKING
OPENSSL_NO_MD2
OPENSSL_NO_MD4
OPENSSL_NO_MD5
OPENSSL_NO_MDC2
OPENSSL_NO_RC2
OPENSSL_NO_RC4
OPENSSL_NO_RC5
OPENSSL_NO_RMD160
OPENSSL_NO_RSA
OPENSSL_NO_SHA
OPENSSL_NO_SHA1
OPENSSL_NO_SOCK
OPENSSL_NO_SSL2
OPENSSL_NO_SPEED
OPENSSL_NO_STDIO
OPENSSL_NO_X509
OPENSSL_SYS_AIX
OPENSSL_SYS_CRAY
OPENSSL_SYS_LINUX
OPENSSL_SYS_MACINTOSH_CLASSIC
OPENSSL_SYS_MACOSX
OPENSSL_SYS_MACOSX_RHAPSODY
OPENSSL_SYS_MPE
OPENSSL_SYS_MSDOS
OPENSSL_SYS_NEWS4
OPENSSL_SYS_OS2
OPENSSL_SYS_SNI
OPENSSL_SYS_SUNOS
OPENSSL_SYS_ULTRASPARC
OPENSSL_SYS_VMS
OPENSSL_SYS_VMS_DECC
OPENSSL_SYS_VMS_DECCXX
OPENSSL_SYS_VMS_NODECC
OPENSSL_SYS_VXWORKS
OPENSSL_SYS_WIN16
OPENSSL_SYS_WIN32
OPENSSL_SYS_WIN32_CYGWIN
OPENSSL_SYS_WIN32_UWIN
OPENSSL_SYS_WINCE
OPENSSL_SYS_WINDOWS
OPENSSL_SYS_WINNT
OPENSSL_NO_KRB5
PEDANTIC
EOF
$unifdef = $unifdef0;
$unifdef =~ s/\n$//;
$unifdef =~ s/^/-U/;
$unifdef =~ s/\n/\n-U/g;
$unifdef =~ s/\n/ /g;
$unifdef =~ join("\n", $unifdef);
#$unifdef1 = <<EOF;
#EOF
$files = `find . -name \\\*.h -print | grep -v MacOS`;
$unifdef0 =~ s/\n$//;
$unifdef0 =~ s/^/-U/;
$unifdef0 =~ s/\n/\n-U/g;
$unifdef0 =~ s/\n/ /g;
$unifdef0 =~ join("\n", $unifdef);
#$unifdef1 =~ s/\n$//;
#$unifdef1 =~ s/^/-D/;
#$unifdef1 =~ s/\n/\n-D/g;
#$unifdef1 =~ s/\n/ /g;
#$unifdef1 =~ join("\n", $unifdef);
#$unifdef = $unifdef0 . ' ' . $unifdef1;
$unifdef = $unifdef0;
$files = `find . -name \\\*.h -type f -print | grep -v MacOS`;
foreach $i (split(/[\n ]/, $files)) {
print "unifdef $unifdef <$i >$tmp\n";
print "mv $tmp $i\n";
}
#unifdef =~ s/-D/-DOPENSSL_/;
$files = `find . -name \\\*.h -type f -print | grep -v MacOS`;
foreach $i (split(/[\n ]/, $files)) {
print "unifdef $unifdef <$i >$tmp\n";
print "mv $tmp $i\n";
}