summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Laurie <ben@openssl.org>2007-10-04 08:01:21 +0000
committerBen Laurie <ben@openssl.org>2007-10-04 08:01:21 +0000
commiteb4a1027ae459ad0bf6f9b5a81735d49654fbc07 (patch)
treef69742d7b807fbcd9cc2e30df17330e8707c73b2
parentd0fc03327efac736821be3581a92843331f51293 (diff)
downloadopenssl-new-eb4a1027ae459ad0bf6f9b5a81735d49654fbc07.tar.gz
Fix off-by-one.
-rw-r--r--ssl/ssl_lib.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 4e8f302a5e..e9fda28f63 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -1169,7 +1169,6 @@ int SSL_set_cipher_list(SSL *s,const char *str)
char *SSL_get_shared_ciphers(const SSL *s,char *buf,int len)
{
char *p;
- const char *cp;
STACK_OF(SSL_CIPHER) *sk;
SSL_CIPHER *c;
int i;
@@ -1182,20 +1181,21 @@ char *SSL_get_shared_ciphers(const SSL *s,char *buf,int len)
sk=s->session->ciphers;
for (i=0; i<sk_SSL_CIPHER_num(sk); i++)
{
- /* Decrement for either the ':' or a '\0' */
- len--;
+ int n;
+
c=sk_SSL_CIPHER_value(sk,i);
- for (cp=c->name; *cp; )
+ n=strlen(c->name);
+ if (n+1 > len)
{
- if (len-- <= 0)
- {
- *p='\0';
- return(buf);
- }
- else
- *(p++)= *(cp++);
+ if (p != buf)
+ --p;
+ *p='\0';
+ return buf;
}
+ strcpy(p,c->name);
+ p+=n;
*(p++)=':';
+ len-=n+1;
}
p[-1]='\0';
return(buf);