From 4348ad76758ba2fd547d7a9ae046833bfe33e669 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Tue, 16 Jun 2020 13:51:21 -0400 Subject: [PATCH] Truncate freedns passwords longer than 16 chars Fixes #176 --- ChangeLog.md | 4 ++++ ddclient | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 68abea5..4dff5f3 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -9,6 +9,10 @@ repository history](https://github.com/ddclient/ddclient/commits/master). * Added support for OVH DynHost. +### Bug fixes + + * Fixed freedns.afraid.org for passwords longer than 16 characters. + ### Compatibility and dependency changes * Perl v5.10.1 or later is now required. diff --git a/ddclient b/ddclient index f3b16f5..79e3ee3 100755 --- a/ddclient +++ b/ddclient @@ -3844,7 +3844,11 @@ sub nic_freedns_update { ## First get the list of updatable hosts 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); if (!defined($reply) || !$reply || !header_ok($_[0], $reply)) { failed("updating %s: Could not connect to %s for site list.", $_[0], $url);