1
0
Fork 0
mirror of git://sourceware.org/git/glibc.git synced 2025-03-06 20:58:33 +01:00

hurd: Fix FS_RETRY_MAGICAL "machtype" handling

We need to set file_name, not update retryname. This is what the other
branches do.

Before this change, any attempt to access such a file would segfault due
to file_name being unset:

$ settrans -ac /tmp/my-machtype /hurd/magic machtype
$ cat /tmp/my-machtype
Segmentation fault

Checked on i686-gnu.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230429131354.2507443-7-bugaevc@gmail.com>
This commit is contained in:
Sergey Bugaev 2023-04-29 16:13:54 +03:00 committed by Samuel Thibault
parent 89f1e04174
commit f56ad6174c

View file

@ -277,7 +277,6 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
error_t err; error_t err;
struct host_basic_info hostinfo; struct host_basic_info hostinfo;
mach_msg_type_number_t hostinfocnt = HOST_BASIC_INFO_COUNT; mach_msg_type_number_t hostinfocnt = HOST_BASIC_INFO_COUNT;
char *p;
/* XXX want client's host */ /* XXX want client's host */
if (err = __host_info (__mach_host_self (), HOST_BASIC_INFO, if (err = __host_info (__mach_host_self (), HOST_BASIC_INFO,
(integer_t *) &hostinfo, (integer_t *) &hostinfo,
@ -288,13 +287,11 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
err = EGRATUITOUS; err = EGRATUITOUS;
goto out; goto out;
} }
p = _itoa (hostinfo.cpu_subtype, &retryname[8], 10, 0); file_name = _itoa (hostinfo.cpu_subtype, &retryname[8], 10, 0);
*--p = '/'; *--file_name = '/';
p = _itoa (hostinfo.cpu_type, &retryname[8], 10, 0); file_name = _itoa (hostinfo.cpu_type, file_name, 10, 0);
if (p < retryname) if (file_name < retryname)
abort (); /* XXX write this right if this ever happens */ abort (); /* XXX write this right if this ever happens */
if (p > retryname)
memmove (retryname, p, strlen(p) + 1);
startdir = *result; startdir = *result;
} }
else else