1
0
mirror of https://github.com/openbsd/src.git synced 2026-05-01 09:37:02 +00:00

Call realpath on the source file to match -f on the command line, GitHub

issue 4180.
This commit is contained in:
nicm
2024-10-12 08:20:32 +00:00
parent 232cb8cb3a
commit 38cf620f4e

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: cmd-source-file.c,v 1.54 2023/09/15 06:31:49 nicm Exp $ */
/* $OpenBSD: cmd-source-file.c,v 1.55 2024/10/12 08:20:32 nicm Exp $ */
/*
* Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org>
@@ -122,6 +122,14 @@ cmd_source_file_done(struct client *c, const char *path, int error,
static void
cmd_source_file_add(struct cmd_source_file_data *cdata, const char *path)
{
char resolved[PATH_MAX];
if (realpath(path, resolved) == NULL) {
log_debug("%s: realpath(\"%s\") failed: %s", __func__,
path, strerror(errno));
} else
path = resolved;
log_debug("%s: %s", __func__, path);
cdata->files = xreallocarray(cdata->files, cdata->nfiles + 1,
sizeof *cdata->files);