Not sure this is sensible as it encourages people to simply update the table.
I was inclined to remove the code entirely but I am not sure what broken systems might rely on this. Only build tested. Thoughts? Index: b_sock.c =================================================================== RCS file: /cvs/src/lib/libssl/src/crypto/bio/b_sock.c,v retrieving revision 1.33 diff -u -p -r1.33 b_sock.c --- b_sock.c 26 Apr 2014 18:56:37 -0000 1.33 +++ b_sock.c 29 Apr 2014 13:55:39 -0000 @@ -140,6 +140,19 @@ BIO_get_port(const char *str, unsigned s { int i; struct servent *s; + size_t len; + struct { + const char *name; + int port; + } servmap[] = { + { "http", 80 }, + { "telnet", 23 }, + { "socks", 1080 }, + { "https", 443 }, + { "ssl", 443 }, + { "ftp", 21 }, + { "gopher", 70 } + }; if (str == NULL) { BIOerr(BIO_F_BIO_GET_PORT, BIO_R_NO_PORT_DEFINED); @@ -155,21 +168,14 @@ BIO_get_port(const char *str, unsigned s *port_ptr = ntohs((unsigned short)s->s_port); CRYPTO_w_unlock(CRYPTO_LOCK_GETSERVBYNAME); if (s == NULL) { - if (strcmp(str, "http") == 0) - *port_ptr = 80; - else if (strcmp(str, "telnet") == 0) - *port_ptr = 23; - else if (strcmp(str, "socks") == 0) - *port_ptr = 1080; - else if (strcmp(str, "https") == 0) - *port_ptr = 443; - else if (strcmp(str, "ssl") == 0) - *port_ptr = 443; - else if (strcmp(str, "ftp") == 0) - *port_ptr = 21; - else if (strcmp(str, "gopher") == 0) - *port_ptr = 70; - else { + len = sizeof(servmap) / sizeof(servmap[0]); + for (i = 0; i < len; i++) { + if (strcmp(str, servmap[i].name) == 0) { + *port_ptr = servmap[i].port; + break; + } + } + if (i == len) { SYSerr(SYS_F_GETSERVBYNAME, errno); ERR_asprintf_error_data("service='%s'", str); return (0);