* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include <target/target_request.h>
#include <helper/configuration.h>
-static const char *telnet_port;
+static char *telnet_port;
static char *negotiate =
"\xFF\xFB\x03" /* IAC WILL Suppress Go Ahead */
static int telnet_new_connection(struct connection *connection)
{
- struct telnet_connection *telnet_connection = malloc(sizeof(struct telnet_connection));
+ struct telnet_connection *telnet_connection;
struct telnet_service *telnet_service = connection->service->priv;
int i;
+ telnet_connection = malloc(sizeof(struct telnet_connection));
+
+ if (!telnet_connection) {
+ LOG_ERROR("Failed to allocate telnet connection.");
+ return ERROR_FAIL;
+ }
+
connection->priv = telnet_connection;
/* initialize telnet connection information */
return ERROR_OK;
}
- struct telnet_service *telnet_service = malloc(sizeof(struct telnet_service));
+ struct telnet_service *telnet_service;
+
+ telnet_service = malloc(sizeof(struct telnet_service));
+
+ if (!telnet_service) {
+ LOG_ERROR("Failed to allocate telnet service.");
+ return ERROR_FAIL;
+ }
telnet_service->banner = banner;
return add_service("telnet",
telnet_port,
- 1,
+ CONNECTION_LIMIT_UNLIMITED,
telnet_new_connection,
telnet_input,
telnet_connection_closed,