Truncate freedns passwords longer than 16 chars

Fixes #176
This commit is contained in:
Richard Hansen 2020-06-16 13:51:21 -04:00
parent 7cc36539e7
commit 4348ad7675
2 changed files with 9 additions and 1 deletions

View file

@ -9,6 +9,10 @@ repository history](https://github.com/ddclient/ddclient/commits/master).
* Added support for OVH DynHost. * Added support for OVH DynHost.
### Bug fixes
* Fixed freedns.afraid.org for passwords longer than 16 characters.
### Compatibility and dependency changes ### Compatibility and dependency changes
* Perl v5.10.1 or later is now required. * Perl v5.10.1 or later is now required.

View file

@ -3844,7 +3844,11 @@ sub nic_freedns_update {
## First get the list of updatable hosts ## First get the list of updatable hosts
my $url; my $url;
$url = "http://$config{$_[0]}{'server'}/api/?action=getdyndns&sha=" . &sha1_hex("$config{$_[0]}{'login'}|$config{$_[0]}{'password'}"); # https://freedns.afraid.org/api/ says, "Password is maximum length of 16 characters."
# Experimentation has shown that this means that longer passwords must be truncated.
my $truncated_password = substr($config{$_[0]}{'password'}, 0, 16);
my $hashed_creds = sha1_hex("$config{$_[0]}{'login'}|$truncated_password");
$url = "http://$config{$_[0]}{'server'}/api/?action=getdyndns&sha=" . $hashed_creds;
my $reply = geturl(opt('proxy'), $url); my $reply = geturl(opt('proxy'), $url);
if (!defined($reply) || !$reply || !header_ok($_[0], $reply)) { if (!defined($reply) || !$reply || !header_ok($_[0], $reply)) {
failed("updating %s: Could not connect to %s for site list.", $_[0], $url); failed("updating %s: Could not connect to %s for site list.", $_[0], $url);