*/
static char *busybox_fullpath()
{
- char proc[256];
-
- sprintf(proc, "/proc/%d/exe", getpid());
- return xreadlink(proc);
+ return xreadlink("/proc/self/exe");
}
/* create (sym)links for each applet */
strncpy(header.linkname, tbInfo->hlInfo->name, sizeof(header.linkname));
} else if (S_ISLNK(statbuf->st_mode)) {
char *lpath = xreadlink(real_name);
+ if (!lpath) /* Already printed err msg inside xreadlink() */
+ return ( FALSE);
header.typeflag = SYMTYPE;
strncpy(header.linkname, lpath, sizeof(header.linkname));
free(lpath);
*/
static char *busybox_fullpath()
{
- char proc[256];
-
- sprintf(proc, "/proc/%d/exe", getpid());
- return xreadlink(proc);
+ return xreadlink("/proc/self/exe");
}
/* create (sym)links for each applet */
/*
- * xreadlink.c - safe implementation of readlink
+ * xreadlink.c - safe implementation of readlink.
+ * Returns a NULL on failure...
*/
#include <stdio.h>
do {
buf = xrealloc(buf, bufsize += GROWBY);
readsize = readlink(path, buf, bufsize); /* 1st try */
- if (readsize == -1)
- perror_msg("%s:%s", applet_name, path);
+ if (readsize == -1) {
+ perror_msg("%s:%s", applet_name, path);
+ return NULL;
+ }
}
while (bufsize < readsize + 1);
show_usage();
buf = xreadlink(argv[1]);
+ if (!buf)
+ return EXIT_FAILURE;
puts(buf);
#ifdef BB_FEATURE_CLEAN_UP
free(buf);
show_usage();
buf = xreadlink(argv[1]);
+ if (!buf)
+ return EXIT_FAILURE;
puts(buf);
#ifdef BB_FEATURE_CLEAN_UP
free(buf);
strncpy(header.linkname, tbInfo->hlInfo->name, sizeof(header.linkname));
} else if (S_ISLNK(statbuf->st_mode)) {
char *lpath = xreadlink(real_name);
+ if (!lpath) /* Already printed err msg inside xreadlink() */
+ return ( FALSE);
header.typeflag = SYMTYPE;
strncpy(header.linkname, lpath, sizeof(header.linkname));
free(lpath);