1. an occurrence of ${ORIGIN} before $ORIGIN would be ignored due to
the strstr logic. (note that rpath contains multiple :-delimited paths
to be searched.)
2. data read by readlink was not null-terminated.
}
n = 0;
s = p->rpath_orig;
}
n = 0;
s = p->rpath_orig;
- while ((t=strstr(s, "$ORIGIN")) || (t=strstr(s, "${ORIGIN}"))) {
+ while ((t=strchr(s, '$'))) {
+ if (strncmp(t, "$ORIGIN", 7) && strncmp(t, "${ORIGIN}", 9))
+ return -1;
* (either system paths or a call to dlopen). */
if (libc.secure)
return -1;
* (either system paths or a call to dlopen). */
if (libc.secure)
return -1;
- if (readlink("/proc/self/exe", buf, buf_size) >= buf_size)
+ l = readlink("/proc/self/exe", buf, buf_size);
+ if (l >= buf_size)
origin = buf;
} else {
origin = p->name;
origin = buf;
} else {
origin = p->name;
d = p->rpath;
s = p->rpath_orig;
d = p->rpath;
s = p->rpath_orig;
- while ((t=strstr(s, "$ORIGIN")) || (t=strstr(s, "${ORIGIN}"))) {
+ while ((t=strchr(s, '$'))) {
memcpy(d, s, t-s);
d += t-s;
memcpy(d, origin, l);
d += l;
memcpy(d, s, t-s);
d += t-s;
memcpy(d, origin, l);
d += l;
+ /* It was determined previously that the '$' is followed
+ * either by "ORIGIN" or "{ORIGIN}". */
s = t + 7 + 2*(t[1]=='{');
}
strcpy(d, s);
s = t + 7 + 2*(t[1]=='{');
}
strcpy(d, s);