Off by one fix from stable branch.

This commit is contained in:
Dr. Stephen Henson 2007-10-04 12:07:52 +00:00
parent 0023adb47a
commit 4f19a9cb9f

View File

@ -1277,7 +1277,6 @@ int SSL_set_cipher_list(SSL *s,const char *str)
char *SSL_get_shared_ciphers(const SSL *s,char *buf,int len) char *SSL_get_shared_ciphers(const SSL *s,char *buf,int len)
{ {
char *p; char *p;
const char *cp;
STACK_OF(SSL_CIPHER) *sk; STACK_OF(SSL_CIPHER) *sk;
SSL_CIPHER *c; SSL_CIPHER *c;
int i; int i;
@ -1290,20 +1289,21 @@ char *SSL_get_shared_ciphers(const SSL *s,char *buf,int len)
sk=s->session->ciphers; sk=s->session->ciphers;
for (i=0; i<sk_SSL_CIPHER_num(sk); i++) for (i=0; i<sk_SSL_CIPHER_num(sk); i++)
{ {
/* Decrement for either the ':' or a '\0' */ int n;
len--;
c=sk_SSL_CIPHER_value(sk,i); c=sk_SSL_CIPHER_value(sk,i);
for (cp=c->name; *cp; ) n=strlen(c->name);
if (n+1 > len)
{ {
if (len-- <= 0) if (p != buf)
{ --p;
*p='\0'; *p='\0';
return(buf); return buf;
}
else
*(p++)= *(cp++);
} }
strcpy(p,c->name);
p+=n;
*(p++)=':'; *(p++)=':';
len-=n+1;
} }
p[-1]='\0'; p[-1]='\0';
return(buf); return(buf);