From: Miroslav Lichvar Date: Mon, 24 Feb 2020 17:05:09 +0000 (+0100) Subject: sources: don't save or load dumpfiles for unknown addresses X-Git-Tag: 4.0-pre1~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=672b98dd3fb17aa7de57d709f1f7b97c0889ec31;p=thirdparty%2Fchrony.git sources: don't save or load dumpfiles for unknown addresses Don't open a dumpfile for reading or writing if the NTP source doesn't have a real address. Fixes: d7e3ad17ff7a ("ntp: create sources for unresolved addresses") --- diff --git a/sources.c b/sources.c index 7ed34a55..71934912 100644 --- a/sources.c +++ b/sources.c @@ -1161,10 +1161,12 @@ FILE *open_dumpfile(SRC_Instance inst, char mode) } /* Include IP address in the name for NTP sources, or reference ID in hex */ - if (inst->type == SRC_NTP) + if (inst->type == SRC_NTP && UTI_IsIPReal(inst->ip_addr)) snprintf(filename, sizeof (filename), "%s", source_to_string(inst)); - else + else if (inst->type == SRC_REFCLOCK) snprintf(filename, sizeof (filename), "refid:%08"PRIx32, inst->ref_id); + else + return NULL; return UTI_OpenFile(dumpdir, filename, ".dat", mode, 0644); }