VERSION = 1
PATCHLEVEL = 7
-SUBLEVEL = 2
+SUBLEVEL = 3
EXTRAVERSION =
NAME = Unnamed
static ssize_t tail_read(int fd, char *buf, size_t count)
{
ssize_t r;
- off_t current, end;
+ off_t current;
struct stat sbuf;
- end = current = lseek(fd, 0, SEEK_CUR);
- if (!fstat(fd, &sbuf))
- end = sbuf.st_size;
- lseek(fd, end < current ? 0 : current, SEEK_SET);
+ /* (A good comment is missing here) */
+ current = lseek(fd, 0, SEEK_CUR);
+ /* /proc files report zero st_size, don't lseek them. */
+ if (fstat(fd, &sbuf) == 0 && sbuf.st_size)
+ if (sbuf.st_size < current)
+ lseek(fd, 0, SEEK_SET);
+
r = safe_read(fd, buf, count);
if (r < 0) {
bb_perror_msg(bb_msg_read_error);
static unsigned eat_num(const char *p)
{
- if (*p == '-') p++;
- else if (*p == '+') { p++; G.status = EXIT_FAILURE; }
+ if (*p == '-')
+ p++;
+ else if (*p == '+') {
+ p++;
+ G.status = EXIT_FAILURE;
+ }
return xatou_sfx(p, tail_suffixes);
}
extern void bb_do_delay(int seconds);
extern void change_identity(const struct passwd *pw);
extern const char *change_identity_e2str(const struct passwd *pw);
-extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args);
+extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args) ATTRIBUTE_NORETURN;
#if ENABLE_SELINUX
extern void renew_current_security_context(void);
extern void set_current_security_context(security_context_t sid);
* and send it to the peer. So please no SIGPIPEs! */
signal(SIGPIPE, SIG_IGN);
+ /* Accound for POSTDATA already in hdr_buf */
+ bodyLen -= hdr_cnt;
+
/* This loop still looks messy. What is an exit criteria?
* "CGI's output closed"? Or "CGI has exited"?
* What to do if CGI has closed both input and output, but
/* if ((arg = skip(&cp, 1)) == NULL) */
/* goto more; */
- sep->se_server = xxstrdup(skip(&cp));
+ arg = skip(&cp);
+ sep->se_server = xxstrdup(arg);
if (strcmp(sep->se_server, "internal") == 0) {
#ifdef INETD_FEATURE_ENABLED
const struct builtin *bi;
sep->se_bi = NULL;
#endif
argc = 0;
- for (arg = skip(&cp); cp; arg = skip(&cp)) {
+ for (; cp; arg = skip(&cp)) {
if (argc < MAXARGV)
sep->se_argv[argc++] = xxstrdup(arg);
}
} else if (key == ARG_remote) {
NEXT_ARG();
key = index_in_strings(keywords, *argv);
- if (key == ARG_any)
+ if (key != ARG_any)
p->iph.daddr = get_addr32(*argv);
} else if (key == ARG_local) {
NEXT_ARG();
key = index_in_strings(keywords, *argv);
- if (key == ARG_any)
+ if (key != ARG_any)
p->iph.saddr = get_addr32(*argv);
} else if (key == ARG_dev) {
NEXT_ARG();
/* Lives far away from here, needed for forkchild */
static void closescript(void);
+
/* Called after fork(), in child */
static void
forkchild(struct job *jp, union node *n, int mode)
setsignal(SIGQUIT);
setsignal(SIGTERM);
}
-#if JOBS
- /* For "jobs | cat" to work like in bash, we must retain list of jobs
- * in child, but we do need to remove ourself */
- if (jp)
- freejob(jp);
-#else
for (jp = curjob; jp; jp = jp->prev_job)
freejob(jp);
-#endif
jobless = 0;
}
argv += optind;
if (!argc) {
#define strbuf bb_common_bufsiz1
- while (fgets(strbuf, BUFSIZ, stdin)) {
+ while (fgets(strbuf, COMMON_BUFSIZE, stdin)) {
if (strbuf[0]
&& NOT_LONE_CHAR(strbuf, '\n')
) {
}
} else {
char *message = NULL;
- int len = 1; /* for NUL */
+ int len = 0;
int pos = 0;
do {
len += strlen(*argv) + 1;
- message = xrealloc(message, len);
+ message = xrealloc(message, len + 1);
sprintf(message + pos, " %s", *argv),
pos = len;
} while (*++argv);