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

stubs.c: use of undeclared identifier 'PATH_MAX' #46

Closed
251 opened this issue Oct 18, 2013 · 1 comment
Closed

stubs.c: use of undeclared identifier 'PATH_MAX' #46

251 opened this issue Oct 18, 2013 · 1 comment

Comments

@251
Copy link
Contributor

251 commented Oct 18, 2013

runtime/POSIX/stubs.c uses an undefined PATH_MAX on my Linux system:

char *canonicalize_file_name (const char *name) __attribute__((weak));
char *canonicalize_file_name (const char *name) {
  char *res = malloc(PATH_MAX);
  char *rp_res = realpath(name, res);
  if (!rp_res)
    free(res);
  return rp_res;
}

It's afaik neither in the C standards nor included with the default option -D _GNU_SOURCE. There are multiple options to resolve this issue. Instead of including linux/limits.h I'd recommend using POSIX_C_SOURCE 200809L/ _XOPEN_SOURCE 700 and pruning canonicalize_file_name to:

char *canonicalize_file_name (const char *name) {
  return realpath(name, NULL);
}

Should work for BSD's libc, glibc, musl...

@ccadar
Copy link
Contributor

ccadar commented Oct 18, 2013

Thanks, Frank, the latter option is indeed the right thing to do. In fact the man page for canonicalize_file_name says "The call canonicalize_file_name(path) is equivalent to the call realpath(path, NULL).
Would you like to submit a patch via a pull request? Thanks!

ccadar added a commit that referenced this issue Oct 20, 2013
Simplified implementation of canonicalize_file_name().  Addresses #46.
@ccadar ccadar closed this as completed Oct 20, 2013
251 added a commit to 251/klee that referenced this issue Sep 3, 2018
Fixes klee#46 and reverts klee#47. As stated in klee#46 the solution works for
musl, glibc etc. BUT the code in stub.c is executed by uclibc and
uclibc doesn't allocate the target buffer in realpath.
251 added a commit to 251/klee that referenced this issue Sep 3, 2018
Fixes klee#46 and reverts klee#47. As stated in klee#46, the solution works for
musl, glibc etc. However, the code in stub.c is executed by uclibc
and uclibc doesn't allocate the target buffer in realpath. The
segfault occured while running df with DFS.
251 added a commit to 251/klee that referenced this issue Sep 3, 2018
Fixes klee#46 and reverts klee#47. As stated in klee#46, the solution works for
musl, glibc etc. However, the code in stub.c is executed by uclibc
and uclibc doesn't allocate the target buffer in realpath. The
segfault occured while running df with DFS.
251 added a commit to 251/klee that referenced this issue Sep 3, 2018
Fixes klee#46 and reverts klee#47. As stated in klee#46, the solution works for
musl, glibc etc. However, the code in stub.c is executed by uclibc
and uclibc doesn't allocate the target buffer in realpath. The
segfault occured while running df with DFS.
251 added a commit to 251/klee that referenced this issue Sep 4, 2018
Fixes klee#46 and reverts klee#47. As stated in klee#46, the solution works for
musl, glibc etc. However, the code in stub.c is executed by uclibc
and uclibc doesn't allocate the target buffer in realpath. The
memory error occured while running df for 10min with DFS.
251 added a commit to 251/klee that referenced this issue Sep 4, 2018
Fixes klee#46 and reverts klee#47. As stated in klee#46, the solution works for
musl, glibc etc. However, the code in stub.c is executed by uclibc
and uclibc doesn't allocate the target buffer in realpath. The
memory error occured while running df for 10min with DFS.
251 added a commit to 251/klee that referenced this issue Sep 4, 2018
Fixes klee#46 and reverts klee#47. As stated in klee#46, the solution works for
musl, glibc etc. However, the code in stub.c is executed by uclibc
and uclibc doesn't allocate the target buffer in realpath. The
memory error occured while running df for 10min with DFS.
251 added a commit to 251/klee that referenced this issue Sep 4, 2018
Fixes klee#46 and reverts klee#47. As stated in klee#46, the solution works for
musl, glibc etc. However, the code in stub.c is executed by uclibc
and uclibc doesn't allocate the target buffer in realpath. The
memory error occured while running df for 10min with DFS.
251 added a commit to 251/klee that referenced this issue Sep 4, 2018
Fixes klee#46 and reverts klee#47. As stated in klee#46, the solution works for
musl, glibc etc. However, the code in stub.c is executed by uclibc
and uclibc doesn't allocate the target buffer in realpath. The
memory error occured while running df for 10min with DFS.
251 added a commit to 251/klee that referenced this issue Sep 4, 2018
Fixes klee#46 and reverts klee#47. As stated in klee#46, the solution works for
musl, glibc etc. However, the code in stub.c is executed by uclibc
and uclibc doesn't allocate the target buffer in realpath. The
memory error occured while running df for 10min with DFS.
ccadar pushed a commit that referenced this issue Sep 6, 2018
Fixes #46 and reverts #47. As stated in #46, the solution works for
musl, glibc etc. However, the code in stub.c is executed by uclibc
and uclibc doesn't allocate the target buffer in realpath. The
memory error occured while running df for 10min with DFS.
ccadar pushed a commit to ccadar/klee that referenced this issue Oct 4, 2018
Fixes klee#46 and reverts klee#47. As stated in klee#46, the solution works for
musl, glibc etc. However, the code in stub.c is executed by uclibc
and uclibc doesn't allocate the target buffer in realpath. The
memory error occured while running df for 10min with DFS.
sebymiano pushed a commit to sebymiano/klee that referenced this issue Jun 3, 2019
Fixes klee#46 and reverts klee#47. As stated in klee#46, the solution works for
musl, glibc etc. However, the code in stub.c is executed by uclibc
and uclibc doesn't allocate the target buffer in realpath. The
memory error occured while running df for 10min with DFS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants