Skip to content

Commit 0d334d8

Browse files
author
cameronrich
committed
* PT_APP_PROTOCOL_DATA has a test for hs_status=SSL_OK to prevent possible exchanges before the handshake is complete.
* Changed license on sha256.c to full BSD. git-svn-id: svn://svn.code.sf.net/p/axtls/code/trunk@244 9a5d90b5-6617-0410-8a86-bb477d3ed2e3
1 parent 6711169 commit 0d334d8

File tree

3 files changed

+14
-27
lines changed

3 files changed

+14
-27
lines changed

crypto/sha256.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, Cameron Rich
2+
* Copyright (C) 2001-2003 Christophe Devine
33
*
44
* All rights reserved.
55
*
@@ -28,26 +28,6 @@
2828
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31-
/*
32-
* FIPS-180-2 compliant SHA-256 implementation
33-
*
34-
* Copyright (C) 2001-2003 Christophe Devine
35-
*
36-
* This program is free software; you can redistribute it and/or modify
37-
* it under the terms of the GNU General Public License as published by
38-
* the Free Software Foundation; either version 2 of the License, or
39-
* (at your option) any later version.
40-
*
41-
* This program is distributed in the hope that it will be useful,
42-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
43-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44-
* GNU General Public License for more details.
45-
*
46-
* You should have received a copy of the GNU General Public License
47-
* along with this program; if not, write to the Free Software
48-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
49-
*/
50-
5131
#include <string.h>
5232
#include "os_port.h"
5333
#include "crypto.h"

ssl/gen_cert.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, Cameron Rich
2+
* Copyright (c) 2007-2014, Cameron Rich
33
*
44
* All rights reserved.
55
*
@@ -142,7 +142,7 @@ static int gen_dn(const char *name, uint8_t dn_type,
142142
buf[(*offset)++] = dn_type;
143143
buf[(*offset)++] = ASN1_PRINTABLE_STR;
144144
buf[(*offset)++] = name_size;
145-
strcpy(&buf[*offset], name);
145+
strcpy((char *)&buf[*offset], name);
146146
*offset += name_size;
147147

148148
error:
@@ -165,7 +165,13 @@ static int gen_issuer(const char * dn[], uint8_t *buf, int *offset)
165165
gethostname(fqdn, sizeof(fqdn));
166166
fqdn_len = strlen(fqdn);
167167
fqdn[fqdn_len++] = '.';
168-
getdomainname(&fqdn[fqdn_len], sizeof(fqdn)-fqdn_len);
168+
169+
if (getdomainname(&fqdn[fqdn_len], sizeof(fqdn)-fqdn_len) < 0)
170+
{
171+
ret = X509_NOT_OK;
172+
goto error;
173+
}
174+
169175
fqdn_len = strlen(fqdn);
170176

171177
if (fqdn[fqdn_len-1] == '.') /* ensure '.' is not last char */

ssl/tls1.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,13 +1348,14 @@ int basic_read(SSL *ssl, uint8_t **in_data)
13481348
break;
13491349

13501350
case PT_APP_PROTOCOL_DATA:
1351-
if (in_data)
1351+
if (in_data && ssl->hs_status == SSL_OK)
13521352
{
13531353
*in_data = buf; /* point to the work buffer */
13541354
(*in_data)[read_len] = 0; /* null terminate just in case */
1355+
ret = read_len;
13551356
}
1356-
1357-
ret = read_len;
1357+
else
1358+
ret = SSL_ERROR_INVALID_PROT_MSG;
13581359
break;
13591360

13601361
case PT_ALERT_PROTOCOL:

0 commit comments

Comments
 (0)