|
| 1 | +/***************************************************************************** |
| 2 | + * ports.c: special ports block list |
| 3 | + ***************************************************************************** |
| 4 | + * Copyright © 2019 Rémi Denis-Courmont |
| 5 | + * |
| 6 | + * This program is free software; you can redistribute it and/or modify it |
| 7 | + * under the terms of the GNU Lesser General Public License as published by |
| 8 | + * the Free Software Foundation; either version 2.1 of the License, or |
| 9 | + * (at your option) any later version. |
| 10 | + * |
| 11 | + * This program is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + * GNU Lesser General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU Lesser General Public License |
| 17 | + * along with this program; if not, write to the Free Software Foundation, |
| 18 | + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
| 19 | + *****************************************************************************/ |
| 20 | + |
| 21 | +#ifdef HAVE_CONFIG_H |
| 22 | +# include <config.h> |
| 23 | +#endif |
| 24 | + |
| 25 | +#include <stdbool.h> |
| 26 | +#include <stdlib.h> |
| 27 | +#include "transport.h" |
| 28 | +#include <vlc_common.h> |
| 29 | + |
| 30 | +/* Must be in ascending order */ |
| 31 | +static const unsigned short blocked_ports[] = { |
| 32 | + 1, // tcpmux |
| 33 | + 7, // echo |
| 34 | + 9, // discard |
| 35 | + 11, // systat |
| 36 | + 13, // daytime |
| 37 | + 15, // netstat |
| 38 | + 17, // QOTD |
| 39 | + 19, // character generator |
| 40 | + 20, // FTP data |
| 41 | + 21, // FTP access |
| 42 | + 22, // SSH |
| 43 | + 23, // Telnet |
| 44 | + 25, // SMTP |
| 45 | + 37, // time |
| 46 | + 42, // name |
| 47 | + 43, // nicname |
| 48 | + 53, // DNS |
| 49 | + 77, // priv-rjs |
| 50 | + 79, // finger |
| 51 | + 87, // ttylink |
| 52 | + 95, // supdup |
| 53 | + 101, // hostriame |
| 54 | + 102, // iso-tsap |
| 55 | + 103, // gppitnp |
| 56 | + 104, // acr-nema |
| 57 | + 109, // POP2 |
| 58 | + 110, // POP3 |
| 59 | + 111, // Sun RPC |
| 60 | + 113, // auth |
| 61 | + 115, // SFTP |
| 62 | + 117, // UUCP path service |
| 63 | + 119, // NNTP (i.e. Usenet) |
| 64 | + 123, // NTP |
| 65 | + 135, // DCE endpoint resolution |
| 66 | + 139, // NetBIOS |
| 67 | + 143, // IMAP2 |
| 68 | + 179, // BGP |
| 69 | + 389, // LDAP |
| 70 | + 465, // SMTP/TLS |
| 71 | + 512, // remote exec |
| 72 | + 513, // remote login |
| 73 | + 514, // remote shell |
| 74 | + 515, // printer |
| 75 | + 526, // tempo |
| 76 | + 530, // courier |
| 77 | + 531, // chat |
| 78 | + 532, // netnews |
| 79 | + 540, // UUCP |
| 80 | + 556, // remotefs |
| 81 | + 563, // NNTP/TLS |
| 82 | + 587, // Submission (i.e. first hop SMTP) |
| 83 | + 601, // rsyslog |
| 84 | + 636, // LDAP/TLS |
| 85 | + 993, // LDAP/TLS |
| 86 | + 995, // POP3/TLS |
| 87 | + 2049, // NFS |
| 88 | + 3659, // Apple SASL |
| 89 | + 4045, // NFS RPC lockd |
| 90 | + 6000, // X11 |
| 91 | + 6665, // IRC |
| 92 | + 6666, // IRC |
| 93 | + 6667, // IRC |
| 94 | + 6668, // IRC |
| 95 | + 6669, // IRC |
| 96 | +}; |
| 97 | + |
| 98 | +static int portcmp(const void *key, const void *entry) |
| 99 | +{ |
| 100 | + const unsigned *port = key; |
| 101 | + const unsigned short *blocked_port = entry; |
| 102 | + |
| 103 | + return ((int)*port) - ((int)*blocked_port); |
| 104 | +} |
| 105 | + |
| 106 | +bool vlc_http_port_blocked(unsigned port) |
| 107 | +{ |
| 108 | + if (port > 0xffff) |
| 109 | + return true; |
| 110 | + |
| 111 | + return bsearch(&port, blocked_ports, ARRAY_SIZE(blocked_ports), |
| 112 | + sizeof (unsigned short), portcmp) != NULL; |
| 113 | +} |
0 commit comments