Skip to content
Snippets Groups Projects
Commit c3299f14 authored by Jan Včelák's avatar Jan Včelák :rocket:
Browse files

zscanner: handle non-FQDN origin in scanner_create()

parent 28b97b58
No related branches found
No related tags found
1 merge request!99zscanner: handle non-FQDN origin in scanner_create()
......@@ -129,7 +129,14 @@ scanner_t* scanner_create(const char *file_name,
s->process_error = &noop;
// Create ORIGIN directive and parse it using scanner to set up origin.
int ret = snprintf(settings, sizeof(settings), "$ORIGIN %s\n", origin);
const char *format;
size_t origin_len = strlen(origin);
if (origin_len > 0 && origin[origin_len - 1] != '.') {
format = "$ORIGIN %s.\n";
} else {
format = "$ORIGIN %s\n";
}
int ret = snprintf(settings, sizeof(settings), format, origin);
if (ret <= 0 || (size_t)ret >= sizeof(settings) ||
scanner_process(settings, settings + ret, true, s) != 0) {
scanner_free(s);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment