Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(459)

Side by Side Diff: net/third_party/nss/ssl/sslsock.c

Issue 9663034: Fix a buffer length bug and nits in the next protocol negotiation (NPN) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * vtables (and methods that call through them) for the 4 types of 2 * vtables (and methods that call through them) for the 4 types of
3 * SSLSockets supported. Only one type is still supported. 3 * SSLSockets supported. Only one type is still supported.
4 * Various other functions. 4 * Various other functions.
5 * 5 *
6 * ***** BEGIN LICENSE BLOCK ***** 6 * ***** BEGIN LICENSE BLOCK *****
7 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 7 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
8 * 8 *
9 * The contents of this file are subject to the Mozilla Public License Version 9 * The contents of this file are subject to the Mozilla Public License Version
10 * 1.1 (the "License"); you may not use this file except in compliance with 10 * 1.1 (the "License"); you may not use this file except in compliance with
(...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 } 1337 }
1338 1338
1339 ssl_GetSSL3HandshakeLock(ss); 1339 ssl_GetSSL3HandshakeLock(ss);
1340 ss->nextProtoCallback = callback; 1340 ss->nextProtoCallback = callback;
1341 ss->nextProtoArg = arg; 1341 ss->nextProtoArg = arg;
1342 ssl_ReleaseSSL3HandshakeLock(ss); 1342 ssl_ReleaseSSL3HandshakeLock(ss);
1343 1343
1344 return SECSuccess; 1344 return SECSuccess;
1345 } 1345 }
1346 1346
1347 /* NextProtoStandardCallback is set as an NPN callback for the case when 1347 /* ssl_NextProtoNegoCallback is set as an NPN callback for the case when
1348 * SSL_SetNextProtoNego is used. 1348 * SSL_SetNextProtoNego is used.
1349 */ 1349 */
1350 static SECStatus 1350 static SECStatus
1351 ssl_NextProtoNegoCallback(void *arg, PRFileDesc *fd, 1351 ssl_NextProtoNegoCallback(void *arg, PRFileDesc *fd,
1352 const unsigned char *protos, unsigned int protos_len, 1352 const unsigned char *protos, unsigned int protos_len,
1353 unsigned char *protoOut, unsigned int *protoOutLen, 1353 unsigned char *protoOut, unsigned int *protoOutLen,
1354 unsigned int protoMaxLen) 1354 unsigned int protoMaxLen)
1355 { 1355 {
1356 unsigned int i, j; 1356 unsigned int i, j;
1357 const unsigned char *result; 1357 const unsigned char *result;
(...skipping 25 matching lines...) Expand all
1383 j += 1 + (unsigned int)ss->opt.nextProtoNego.data[j]; 1383 j += 1 + (unsigned int)ss->opt.nextProtoNego.data[j];
1384 } 1384 }
1385 i += 1 + (unsigned int)protos[i]; 1385 i += 1 + (unsigned int)protos[i];
1386 } 1386 }
1387 1387
1388 pick_first: 1388 pick_first:
1389 ss->ssl3.nextProtoState = SSL_NEXT_PROTO_NO_OVERLAP; 1389 ss->ssl3.nextProtoState = SSL_NEXT_PROTO_NO_OVERLAP;
1390 result = ss->opt.nextProtoNego.data; 1390 result = ss->opt.nextProtoNego.data;
1391 1391
1392 found: 1392 found:
1393 *protoOutLen = result[0];
1394 if (protoMaxLen < result[0]) { 1393 if (protoMaxLen < result[0]) {
1395 PORT_SetError(SEC_ERROR_OUTPUT_LEN); 1394 PORT_SetError(SEC_ERROR_OUTPUT_LEN);
1396 return SECFailure; 1395 return SECFailure;
1397 } 1396 }
1398 memcpy(protoOut, result + 1, result[0]); 1397 memcpy(protoOut, result + 1, result[0]);
1398 *protoOutLen = result[0];
1399 return SECSuccess; 1399 return SECSuccess;
1400 } 1400 }
1401 1401
1402 SECStatus 1402 SECStatus
1403 SSL_SetNextProtoNego(PRFileDesc *fd, const unsigned char *data, 1403 SSL_SetNextProtoNego(PRFileDesc *fd, const unsigned char *data,
1404 unsigned int length) 1404 unsigned int length)
1405 { 1405 {
1406 sslSocket *ss; 1406 sslSocket *ss;
1407 SECStatus rv; 1407 SECStatus rv;
1408 SECItem dataItem = { siBuffer, (unsigned char *) data, length }; 1408 SECItem dataItem = { siBuffer, (unsigned char *) data, length };
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 1442
1443 if (!state || !buf || !bufLen) { 1443 if (!state || !buf || !bufLen) {
1444 PORT_SetError(SEC_ERROR_INVALID_ARGS); 1444 PORT_SetError(SEC_ERROR_INVALID_ARGS);
1445 return SECFailure; 1445 return SECFailure;
1446 } 1446 }
1447 1447
1448 *state = ss->ssl3.nextProtoState; 1448 *state = ss->ssl3.nextProtoState;
1449 1449
1450 if (ss->ssl3.nextProtoState != SSL_NEXT_PROTO_NO_SUPPORT && 1450 if (ss->ssl3.nextProtoState != SSL_NEXT_PROTO_NO_SUPPORT &&
1451 ss->ssl3.nextProto.data) { 1451 ss->ssl3.nextProto.data) {
1452 » *bufLen = ss->ssl3.nextProto.len; 1452 » if (ss->ssl3.nextProto.len > bufLenMax) {
1453 » if (*bufLen > bufLenMax) {
1454 PORT_SetError(SEC_ERROR_OUTPUT_LEN); 1453 PORT_SetError(SEC_ERROR_OUTPUT_LEN);
1455 *bufLen = 0;
1456 return SECFailure; 1454 return SECFailure;
1457 } 1455 }
1458 PORT_Memcpy(buf, ss->ssl3.nextProto.data, ss->ssl3.nextProto.len); 1456 PORT_Memcpy(buf, ss->ssl3.nextProto.data, ss->ssl3.nextProto.len);
1457 *bufLen = ss->ssl3.nextProto.len;
1459 } else { 1458 } else {
1460 *bufLen = 0; 1459 *bufLen = 0;
1461 } 1460 }
1462 1461
1463 return SECSuccess; 1462 return SECSuccess;
1464 } 1463 }
1465 1464
1466 PRFileDesc * 1465 PRFileDesc *
1467 SSL_ReconfigFD(PRFileDesc *model, PRFileDesc *fd) 1466 SSL_ReconfigFD(PRFileDesc *model, PRFileDesc *fd)
1468 { 1467 {
(...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after
2705 loser: 2704 loser:
2706 ssl_DestroySocketContents(ss); 2705 ssl_DestroySocketContents(ss);
2707 ssl_DestroyLocks(ss); 2706 ssl_DestroyLocks(ss);
2708 PORT_Free(ss); 2707 PORT_Free(ss);
2709 ss = NULL; 2708 ss = NULL;
2710 } 2709 }
2711 } 2710 }
2712 return ss; 2711 return ss;
2713 } 2712 }
2714 2713
OLDNEW
« net/third_party/nss/ssl/ssl3ext.c ('K') | « net/third_party/nss/ssl/ssl3ext.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698