Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/SAVE fails in Solaris 10 "Invalid argument" #1042

Closed
zvainio opened this issue May 11, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@zvainio
Copy link

commented May 11, 2019

For some reason Solaris 10 does not accept NULL as a parameter. I remembered that this was an issue while ago with GNU screen also

ERRORS
The realpath() function will fail if:

 EINVAL          Either the file_name or resolved_name  argument is a null pointer.

src/lib-config/write.c

/* expand all symlinks; else we may replace a symlink with a regular file */
dest_name = realpath(base_name, NULL);

It was fixed with this

char realbuf[PATH_MAX];
dest_name = realpath(base_name, realbuf);

After this I'm able to use /SAVE command again

@ailin-nemui

This comment has been minimized.

Copy link
Contributor

commented May 13, 2019

:-(

@ailin-nemui

This comment has been minimized.

Copy link
Contributor

commented May 13, 2019

would this work?

diff --git a/src/lib-config/write.c b/src/lib-config/write.c
index b8ef6156..5dbbd1ed 100644
--- a/src/lib-config/write.c
+++ b/src/lib-config/write.c
@@ -315,6 +315,15 @@ int config_write(CONFIG_REC *rec, const char *fname, int create_mode)
 	/* expand all symlinks; else we may replace a symlink with a regular file */
 	dest_name = realpath(base_name, NULL);
 
+	if (errno == EINVAL) {
+		/* variable path length not supported by glibc < 2.3, Solaris < 11 */
+		char resolved_path[PATH_MAX] = { 0 };
+		errno = 0;
+		if ((dest_name = realpath(base_name, resolved_path)) != NULL) {
+			dest_name = g_strdup(dest_name);
+		}
+	}
+
 	if (dest_name == NULL) {
 		if (errno == ENOENT) {
 			dest_name = g_strdup(base_name);
@zvainio

This comment has been minimized.

Copy link
Author

commented May 13, 2019

That code change works fine for me.

ailin-nemui added a commit to ailin-nemui/irssi that referenced this issue May 13, 2019

fix realpath on old solaris
POSIX.1-2001 did not implement realpath(..., NULL) yet.
Fixes irssi#1042

@ailin-nemui ailin-nemui removed the WIP label May 13, 2019

@ailin-nemui ailin-nemui added this to the 1.2.1 milestone Jun 28, 2019

ailin-nemui added a commit to ailin-nemui/irssi that referenced this issue Jul 9, 2019

fix realpath on old solaris
POSIX.1-2001 did not implement realpath(..., NULL) yet.
Fixes irssi#1042
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.