--- s9core.c	2019-04-02 10:45:31.000000000 +0200
+++ s9core.c.new	2024-06-15 22:39:10.836498069 +0200
@@ -2642,10 +2642,12 @@
 
 int s9_open_input_port(char *path) {
 	int	i = s9_new_port();
+	char *res_path = realpath(path, NULL);
 
 	if (i < 0)
 		return -1;
-	Ports[i] = fopen(path, "r");
+	Ports[i] = fopen(res_path, "r");
+	free(res_path);
 	if (Ports[i] == NULL)
 		return -1;
 	return i;
@@ -2653,10 +2655,12 @@
 
 int s9_open_output_port(char *path, int append) {
 	int	i = s9_new_port();
+	char *res_path = realpath(path, NULL);
 
 	if (i < 0)
 		return -1;
 	Ports[i] = fopen(path, append? "a": "w");
+	free(res_path);
 	if (Ports[i] == NULL)
 		return -1;
 	return i;
@@ -2924,8 +2928,10 @@
 	struct magic	m;
 	int		image_nodes, image_vcells;
 	char		*s;
+	char *res_path = realpath(path, NULL);
 
-	f = fopen(path, "rb");
+	f = fopen(res_path, "rb");
+	free(res_path);
 	if (f == NULL)
 		return "could not open file";
 	if ((s = xfread(&m, sizeof(m), 1, f)) != NULL)
