comparison cli-runopts.c @ 492:b956d6151600

Replace calls to strtoul() with a helper m_str_to_uint()
author Matt Johnston <matt@ucc.asn.au>
date Mon, 22 Sep 2008 14:13:44 +0000
parents 79c657a673ec
children 6cd2152aae0b 66eac4631d88
comparison
equal deleted inserted replaced
491:9dbc0c443497 492:b956d6151600
353 if (opts.recv_window == 0 || opts.recv_window > MAX_RECV_WINDOW) { 353 if (opts.recv_window == 0 || opts.recv_window > MAX_RECV_WINDOW) {
354 dropbear_exit("Bad recv window '%s'", recv_window_arg); 354 dropbear_exit("Bad recv window '%s'", recv_window_arg);
355 } 355 }
356 } 356 }
357 if (keepalive_arg) { 357 if (keepalive_arg) {
358 opts.keepalive_secs = strtoul(keepalive_arg, NULL, 10); 358 if (m_str_to_uint(keepalive_arg, &opts.keepalive_secs) == DROPBEAR_FAILURE) {
359 if (opts.keepalive_secs == 0 && errno == EINVAL) {
360 dropbear_exit("Bad keepalive '%s'", keepalive_arg); 359 dropbear_exit("Bad keepalive '%s'", keepalive_arg);
361 } 360 }
362 } 361 }
363 362
364 #ifdef ENABLE_CLI_NETCAT 363 #ifdef ENABLE_CLI_NETCAT
497 if (strchr(portstr, ':')) { 496 if (strchr(portstr, ':')) {
498 TRACE(("Multiple netcat colons")) 497 TRACE(("Multiple netcat colons"))
499 goto fail; 498 goto fail;
500 } 499 }
501 500
502 cli_opts.netcat_port = strtoul(portstr, NULL, 10); 501 if (m_str_to_uint(portstr, &cli_opts.netcat_port) == DROPBEAR_FAILURE) {
503 if (errno != 0) {
504 TRACE(("bad netcat port")) 502 TRACE(("bad netcat port"))
505 goto fail; 503 goto fail;
506 } 504 }
507 505
508 if (cli_opts.netcat_port > 65535) { 506 if (cli_opts.netcat_port > 65535) {
569 567
570 newfwd = (struct TCPFwdList*)m_malloc(sizeof(struct TCPFwdList)); 568 newfwd = (struct TCPFwdList*)m_malloc(sizeof(struct TCPFwdList));
571 569
572 /* Now we check the ports - note that the port ints are unsigned, 570 /* Now we check the ports - note that the port ints are unsigned,
573 * the check later only checks for >= MAX_PORT */ 571 * the check later only checks for >= MAX_PORT */
574 newfwd->listenport = strtoul(listenport, NULL, 10); 572 if (m_str_to_uint(listenport, &newfwd->listenport) == DROPBEAR_FAILURE) {
575 if (errno != 0) { 573 TRACE(("bad listenport strtoul"))
576 TRACE(("bad listenport strtol")) 574 goto fail;
577 goto fail; 575 }
578 } 576
579 577 if (m_str_to_uint(connectport, &newfwd->connectport) == DROPBEAR_FAILURE) {
580 newfwd->connectport = strtoul(connectport, NULL, 10); 578 TRACE(("bad connectport strtoul"))
581 if (errno != 0) {
582 TRACE(("bad connectport strtol"))
583 goto fail; 579 goto fail;
584 } 580 }
585 581
586 newfwd->connectaddr = connectaddr; 582 newfwd->connectaddr = connectaddr;
587 583