syslogd: fix "readpath bug" by using readlink instead
libbb: rename xgetcwd and xreadlink
This commit is contained in:
@@ -233,7 +233,7 @@ int copy_file(const char *source, const char *dest, int flags)
|
||||
} else if (S_ISLNK(source_stat.st_mode)) {
|
||||
char *lpath;
|
||||
|
||||
lpath = xreadlink(source);
|
||||
lpath = xmalloc_readlink_or_warn(source);
|
||||
if (symlink(lpath, dest) < 0) {
|
||||
bb_perror_msg("cannot create symlink '%s'", dest);
|
||||
free(lpath);
|
||||
|
||||
@@ -1090,7 +1090,7 @@ static void parse_prompt(const char *prmt_ptr)
|
||||
size_t cur_prmt_len = 0;
|
||||
char flg_not_length = '[';
|
||||
char *prmt_mem_ptr = xzalloc(1);
|
||||
char *pwd_buf = xgetcwd(0);
|
||||
char *pwd_buf = xrealloc_getcwd_or_warn(NULL);
|
||||
char buf2[PATH_MAX + 1];
|
||||
char buf[2];
|
||||
char c;
|
||||
|
||||
@@ -16,7 +16,7 @@ char *bb_simplify_path(const char *path)
|
||||
if (path[0] == '/')
|
||||
start = xstrdup(path);
|
||||
else {
|
||||
s = xgetcwd(NULL);
|
||||
s = xrealloc_getcwd_or_warn(NULL);
|
||||
start = concat_path_file(s, path);
|
||||
free(s);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
char *
|
||||
xgetcwd(char *cwd)
|
||||
xrealloc_getcwd_or_warn(char *cwd)
|
||||
{
|
||||
char *ret;
|
||||
unsigned path_max;
|
||||
@@ -26,7 +26,7 @@ xgetcwd(char *cwd)
|
||||
path_max = (unsigned) PATH_MAX;
|
||||
path_max += 2; /* The getcwd docs say to do this. */
|
||||
|
||||
if (cwd==0)
|
||||
if (cwd == NULL)
|
||||
cwd = xmalloc(path_max);
|
||||
|
||||
while ((ret = getcwd(cwd, path_max)) == NULL && errno == ERANGE) {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* yourself. You have been warned.
|
||||
*/
|
||||
|
||||
char *xreadlink(const char *path)
|
||||
char *xmalloc_readlink_or_warn(const char *path)
|
||||
{
|
||||
enum { GROWBY = 80 }; /* how large we will grow strings by */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user