Mercurial > dropbear
comparison cli-runopts.c @ 1936:4528afefe45d
Fix IPv6 address parsing for dbclient -b
Now can correctly handle '-b [ipv6address]:port'
Code is shared with dropbear -p, though they handle colon-less arguments
differently
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 01 Apr 2022 14:13:52 +0800 |
parents | a7ad060707b6 |
children |
comparison
equal
deleted
inserted
replaced
1935:a7ad060707b6 | 1936:4528afefe45d |
---|---|
417 TRACE(("cmd is: %s", cli_opts.cmd)) | 417 TRACE(("cmd is: %s", cli_opts.cmd)) |
418 } | 418 } |
419 | 419 |
420 /* And now a few sanity checks and setup */ | 420 /* And now a few sanity checks and setup */ |
421 | 421 |
422 #if DROPBEAR_CLI_PROXYCMD | 422 #if DROPBEAR_CLI_PROXYCMD |
423 if (cli_opts.proxycmd) { | 423 if (cli_opts.proxycmd) { |
424 /* To match the common path of m_freeing it */ | 424 /* To match the common path of m_freeing it */ |
425 cli_opts.proxycmd = m_strdup(cli_opts.proxycmd); | 425 cli_opts.proxycmd = m_strdup(cli_opts.proxycmd); |
426 } | 426 } |
427 #endif | 427 #endif |
429 if (cli_opts.remoteport == NULL) { | 429 if (cli_opts.remoteport == NULL) { |
430 cli_opts.remoteport = "22"; | 430 cli_opts.remoteport = "22"; |
431 } | 431 } |
432 | 432 |
433 if (bind_arg) { | 433 if (bind_arg) { |
434 /* split [host][:port] */ | 434 if (split_address_port(bind_arg, |
435 char *port = strrchr(bind_arg, ':'); | 435 &cli_opts.bind_address, &cli_opts.bind_port) |
436 if (port) { | 436 == DROPBEAR_FAILURE) { |
437 cli_opts.bind_port = m_strdup(port+1); | 437 dropbear_exit("Bad -b argument"); |
438 *port = '\0'; | |
439 } | |
440 if (strlen(bind_arg) > 0) { | |
441 cli_opts.bind_address = m_strdup(bind_arg); | |
442 } | 438 } |
443 } | 439 } |
444 | 440 |
445 /* If not explicitly specified with -t or -T, we don't want a pty if | 441 /* If not explicitly specified with -t or -T, we don't want a pty if |
446 * there's a command, but we do otherwise */ | 442 * there's a command, but we do otherwise */ |