diff options
Diffstat (limited to 'src/lib/libssl/src/apps/s_server.c')
-rw-r--r-- | src/lib/libssl/src/apps/s_server.c | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/src/lib/libssl/src/apps/s_server.c b/src/lib/libssl/src/apps/s_server.c index 61a77dff11..a107b8c14a 100644 --- a/src/lib/libssl/src/apps/s_server.c +++ b/src/lib/libssl/src/apps/s_server.c | |||
@@ -83,6 +83,7 @@ typedef unsigned int u_int; | |||
83 | #include <openssl/pem.h> | 83 | #include <openssl/pem.h> |
84 | #include <openssl/x509.h> | 84 | #include <openssl/x509.h> |
85 | #include <openssl/ssl.h> | 85 | #include <openssl/ssl.h> |
86 | #include <openssl/rand.h> | ||
86 | #include <openssl/engine.h> | 87 | #include <openssl/engine.h> |
87 | #include "s_apps.h" | 88 | #include "s_apps.h" |
88 | 89 | ||
@@ -245,6 +246,7 @@ static void sv_usage(void) | |||
245 | BIO_printf(bio_err," -bugs - Turn on SSL bug compatibility\n"); | 246 | BIO_printf(bio_err," -bugs - Turn on SSL bug compatibility\n"); |
246 | BIO_printf(bio_err," -www - Respond to a 'GET /' with a status page\n"); | 247 | BIO_printf(bio_err," -www - Respond to a 'GET /' with a status page\n"); |
247 | BIO_printf(bio_err," -WWW - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n"); | 248 | BIO_printf(bio_err," -WWW - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n"); |
249 | BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); | ||
248 | BIO_printf(bio_err," -engine id - Initialise and use the specified engine\n"); | 250 | BIO_printf(bio_err," -engine id - Initialise and use the specified engine\n"); |
249 | } | 251 | } |
250 | 252 | ||
@@ -415,6 +417,8 @@ int MAIN(int argc, char *argv[]) | |||
415 | int no_tmp_rsa=0,no_dhe=0,nocert=0; | 417 | int no_tmp_rsa=0,no_dhe=0,nocert=0; |
416 | int state=0; | 418 | int state=0; |
417 | SSL_METHOD *meth=NULL; | 419 | SSL_METHOD *meth=NULL; |
420 | char *inrand=NULL; | ||
421 | char *engine_id=NULL; | ||
418 | ENGINE *e=NULL; | 422 | ENGINE *e=NULL; |
419 | #ifndef NO_DH | 423 | #ifndef NO_DH |
420 | DH *dh=NULL; | 424 | DH *dh=NULL; |
@@ -570,6 +574,11 @@ int MAIN(int argc, char *argv[]) | |||
570 | else if (strcmp(*argv,"-tls1") == 0) | 574 | else if (strcmp(*argv,"-tls1") == 0) |
571 | { meth=TLSv1_server_method(); } | 575 | { meth=TLSv1_server_method(); } |
572 | #endif | 576 | #endif |
577 | else if (strcmp(*argv,"-rand") == 0) | ||
578 | { | ||
579 | if (--argc < 1) goto bad; | ||
580 | inrand= *(++argv); | ||
581 | } | ||
573 | else if (strcmp(*argv,"-engine") == 0) | 582 | else if (strcmp(*argv,"-engine") == 0) |
574 | { | 583 | { |
575 | if (--argc < 1) goto bad; | 584 | if (--argc < 1) goto bad; |
@@ -591,7 +600,14 @@ bad: | |||
591 | goto end; | 600 | goto end; |
592 | } | 601 | } |
593 | 602 | ||
594 | app_RAND_load_file(NULL, bio_err, 0); | 603 | if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL |
604 | && !RAND_status()) | ||
605 | { | ||
606 | BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n"); | ||
607 | } | ||
608 | if (inrand != NULL) | ||
609 | BIO_printf(bio_err,"%ld semi-random bytes loaded\n", | ||
610 | app_RAND_load_files(inrand)); | ||
595 | 611 | ||
596 | if (bio_s_out == NULL) | 612 | if (bio_s_out == NULL) |
597 | { | 613 | { |
@@ -709,7 +725,8 @@ bad: | |||
709 | 725 | ||
710 | #ifndef NO_RSA | 726 | #ifndef NO_RSA |
711 | #if 1 | 727 | #if 1 |
712 | SSL_CTX_set_tmp_rsa_callback(ctx,tmp_rsa_cb); | 728 | if (!no_tmp_rsa) |
729 | SSL_CTX_set_tmp_rsa_callback(ctx,tmp_rsa_cb); | ||
713 | #else | 730 | #else |
714 | if (!no_tmp_rsa && SSL_CTX_need_tmp_RSA(ctx)) | 731 | if (!no_tmp_rsa && SSL_CTX_need_tmp_RSA(ctx)) |
715 | { | 732 | { |
@@ -1369,15 +1386,29 @@ static int www_body(char *hostname, int s, unsigned char *context) | |||
1369 | 1386 | ||
1370 | /* skip the '/' */ | 1387 | /* skip the '/' */ |
1371 | p= &(buf[5]); | 1388 | p= &(buf[5]); |
1372 | dot=0; | 1389 | |
1390 | dot = 1; | ||
1373 | for (e=p; *e != '\0'; e++) | 1391 | for (e=p; *e != '\0'; e++) |
1374 | { | 1392 | { |
1375 | if (e[0] == ' ') break; | 1393 | if (e[0] == ' ') |
1376 | if ( (e[0] == '.') && | 1394 | break; |
1377 | (strncmp(&(e[-1]),"/../",4) == 0)) | 1395 | |
1378 | dot=1; | 1396 | switch (dot) |
1397 | { | ||
1398 | case 1: | ||
1399 | dot = (e[0] == '.') ? 2 : 0; | ||
1400 | break; | ||
1401 | case 2: | ||
1402 | dot = (e[0] == '.') ? 3 : 0; | ||
1403 | break; | ||
1404 | case 3: | ||
1405 | dot = (e[0] == '/') ? -1 : 0; | ||
1406 | break; | ||
1407 | } | ||
1408 | if (dot == 0) | ||
1409 | dot = (e[0] == '/') ? 1 : 0; | ||
1379 | } | 1410 | } |
1380 | 1411 | dot = (dot == 3) || (dot == -1); /* filename contains ".." component */ | |
1381 | 1412 | ||
1382 | if (*e == '\0') | 1413 | if (*e == '\0') |
1383 | { | 1414 | { |
@@ -1401,9 +1432,11 @@ static int www_body(char *hostname, int s, unsigned char *context) | |||
1401 | break; | 1432 | break; |
1402 | } | 1433 | } |
1403 | 1434 | ||
1435 | #if 0 | ||
1404 | /* append if a directory lookup */ | 1436 | /* append if a directory lookup */ |
1405 | if (e[-1] == '/') | 1437 | if (e[-1] == '/') |
1406 | strcat(p,"index.html"); | 1438 | strcat(p,"index.html"); |
1439 | #endif | ||
1407 | 1440 | ||
1408 | /* if a directory, do the index thang */ | 1441 | /* if a directory, do the index thang */ |
1409 | if (stat(p,&st_buf) < 0) | 1442 | if (stat(p,&st_buf) < 0) |
@@ -1415,7 +1448,13 @@ static int www_body(char *hostname, int s, unsigned char *context) | |||
1415 | } | 1448 | } |
1416 | if (S_ISDIR(st_buf.st_mode)) | 1449 | if (S_ISDIR(st_buf.st_mode)) |
1417 | { | 1450 | { |
1451 | #if 0 /* must check buffer size */ | ||
1418 | strcat(p,"/index.html"); | 1452 | strcat(p,"/index.html"); |
1453 | #else | ||
1454 | BIO_puts(io,text); | ||
1455 | BIO_printf(io,"'%s' is a directory\r\n",p); | ||
1456 | break; | ||
1457 | #endif | ||
1419 | } | 1458 | } |
1420 | 1459 | ||
1421 | if ((file=BIO_new_file(p,"r")) == NULL) | 1460 | if ((file=BIO_new_file(p,"r")) == NULL) |