mirror of https://github.com/mirror/busybox.git
xreadlink: code shrink
udhcp: add missing tryagain member to client_config function old new delta xmalloc_readlink_follow 169 154 -15 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-15) Total: -15 bytes1_9_stable
parent
53bd4015aa
commit
abbd363261
|
@ -41,14 +41,21 @@ char *xmalloc_readlink(const char *path)
|
||||||
*/
|
*/
|
||||||
char *xmalloc_readlink_follow(const char *path)
|
char *xmalloc_readlink_follow(const char *path)
|
||||||
{
|
{
|
||||||
char *buf = NULL, *lpc, *linkpath;
|
char *buf;
|
||||||
|
char *lpc;
|
||||||
|
char *linkpath;
|
||||||
int bufsize;
|
int bufsize;
|
||||||
smallint looping = 0;
|
int looping = MAXSYMLINKS + 1;
|
||||||
|
|
||||||
buf = strdup(path);
|
linkpath = xstrdup(path);
|
||||||
bufsize = strlen(path) + 1;
|
goto jump_in;
|
||||||
|
|
||||||
while(1) {
|
while (1) {
|
||||||
|
if (!--looping) {
|
||||||
|
free(linkpath);
|
||||||
|
free(buf);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
linkpath = xmalloc_readlink(buf);
|
linkpath = xmalloc_readlink(buf);
|
||||||
if (!linkpath) {
|
if (!linkpath) {
|
||||||
if (errno == EINVAL) /* not a symlink */
|
if (errno == EINVAL) /* not a symlink */
|
||||||
|
@ -56,25 +63,19 @@ char *xmalloc_readlink_follow(const char *path)
|
||||||
free(buf);
|
free(buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if (linkpath[0] != '/') {
|
||||||
if (*linkpath == '/') {
|
|
||||||
free(buf);
|
|
||||||
buf = linkpath;
|
|
||||||
bufsize = strlen(linkpath) + 1;
|
|
||||||
} else {
|
|
||||||
bufsize += strlen(linkpath);
|
bufsize += strlen(linkpath);
|
||||||
if (looping++ > MAXSYMLINKS) {
|
|
||||||
free(linkpath);
|
|
||||||
free(buf);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
buf = xrealloc(buf, bufsize);
|
buf = xrealloc(buf, bufsize);
|
||||||
lpc = bb_get_last_path_component_strip(buf);
|
lpc = bb_get_last_path_component_strip(buf);
|
||||||
strcpy(lpc, linkpath);
|
strcpy(lpc, linkpath);
|
||||||
free(linkpath);
|
free(linkpath);
|
||||||
|
} else {
|
||||||
|
free(buf);
|
||||||
|
jump_in:
|
||||||
|
buf = linkpath;
|
||||||
|
bufsize = strlen(buf) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *xmalloc_readlink_or_warn(const char *path)
|
char *xmalloc_readlink_or_warn(const char *path)
|
||||||
|
|
|
@ -305,9 +305,8 @@ int login_main(int argc, char **argv)
|
||||||
openlog(applet_name, LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH);
|
openlog(applet_name, LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
/* flush away any type-ahead (as getty does) */
|
/* flush away any type-ahead (as getty does) */
|
||||||
(void) ioctl(0, TCFLSH, TCIFLUSH);
|
ioctl(0, TCFLSH, TCIFLUSH);
|
||||||
|
|
||||||
if (!username[0])
|
if (!username[0])
|
||||||
get_username_or_die(username, sizeof(username));
|
get_username_or_die(username, sizeof(username));
|
||||||
|
|
|
@ -30,6 +30,7 @@ struct client_config_t {
|
||||||
int ifindex; /* Index number of the interface to use */
|
int ifindex; /* Index number of the interface to use */
|
||||||
int retries; /* Max number of request packets */
|
int retries; /* Max number of request packets */
|
||||||
int timeout; /* Number of seconds to try to get a lease */
|
int timeout; /* Number of seconds to try to get a lease */
|
||||||
|
int tryagain; /* Number of seconds to try to get a lease */
|
||||||
uint8_t arp[6]; /* Our arp address */
|
uint8_t arp[6]; /* Our arp address */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue