mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-07 18:30:28 +00:00
remove realpath from m1 loader
Noticed a bug in the process, pathlen is out of step with n
This commit is contained in:
parent
b08b92248b
commit
6c73ea2bf4
1 changed files with 0 additions and 9 deletions
|
@ -316,21 +316,12 @@ __attribute__((__noreturn__)) static void Pexit(const char *c, int failed,
|
||||||
}
|
}
|
||||||
|
|
||||||
static char AccessCommand(struct PathSearcher *ps, unsigned long pathlen) {
|
static char AccessCommand(struct PathSearcher *ps, unsigned long pathlen) {
|
||||||
char buf[PATH_MAX];
|
|
||||||
size_t n;
|
|
||||||
if (pathlen + 1 + ps->namelen + 1 > sizeof(ps->path)) {
|
if (pathlen + 1 + ps->namelen + 1 > sizeof(ps->path)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (pathlen && ps->path[pathlen - 1] != '/') ps->path[pathlen++] = '/';
|
if (pathlen && ps->path[pathlen - 1] != '/') ps->path[pathlen++] = '/';
|
||||||
memmove(ps->path + pathlen, ps->name, ps->namelen);
|
memmove(ps->path + pathlen, ps->name, ps->namelen);
|
||||||
ps->path[pathlen + ps->namelen] = 0;
|
ps->path[pathlen + ps->namelen] = 0;
|
||||||
if (!realpath(ps->path, buf)) {
|
|
||||||
Pexit(ps->path, -errno, "realpath");
|
|
||||||
}
|
|
||||||
if ((n = strlen(buf)) >= sizeof(ps->path)) {
|
|
||||||
Pexit(buf, 0, "too long");
|
|
||||||
}
|
|
||||||
memcpy(ps->path, buf, n + 1);
|
|
||||||
if (!access(ps->path, X_OK)) {
|
if (!access(ps->path, X_OK)) {
|
||||||
if (ps->indirect) {
|
if (ps->indirect) {
|
||||||
ps->namelen -= 4;
|
ps->namelen -= 4;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue