#endif
};
-static const uint16_t http_response_type[] = {
+static const uint16_t http_response_type[] ALIGN2 = {
HTTP_OK,
HTTP_MOVED_TEMPORARILY,
HTTP_REQUEST_TIMEOUT,
} while (0)
-
-
#define STRNCASECMP(a, str) strncasecmp((a), (str), sizeof(str)-1)
/* Prototypes */
if (flag == SUBDIR_PARSE || cf == NULL) {
cf = alloca(strlen(path) + sizeof(httpd_conf) + 2);
- if (cf == NULL) {
- if (flag == FIRST_PARSE)
- bb_error_msg_and_die(bb_msg_memory_exhausted);
- return;
- }
sprintf((char *)cf, "%s/%s", path, httpd_conf);
}
/* error status code */
int status = atoi(++p0);
/* c already points at the character following ':' in parse loop */
- // c = strchr(p0, ':'); c++;
+ /* c = strchr(p0, ':'); c++; */
if (status < HTTP_CONTINUE) {
bb_error_msg("config error '%s' in '%s'", buf, cf);
continue;
if (*p0 == '/') {
/* make full path from httpd root / current_path / config_line_path */
cf = (flag == SUBDIR_PARSE ? path : "");
- p0 = malloc(strlen(cf) + (c - buf) + 2 + strlen(c));
- if (p0 == NULL)
- continue;
+ p0 = xmalloc(strlen(cf) + (c - buf) + 2 + strlen(c));
c[-1] = '\0';
sprintf(p0, "/%s%s", cf, buf);
char ch;
while ((ch = *string++)) {
- // very simple check for what to encode
- if (isalnum(ch)) *p++ = ch;
- else p += sprintf(p, "&#%d;", (unsigned char) ch);
+ /* very simple check for what to encode */
+ if (isalnum(ch))
+ *p++ = ch;
+ else
+ p += sprintf(p, "&#%d;", (unsigned char) ch);
}
*p = '\0';
return out;
*/
static unsigned hex_to_bin(unsigned char c)
{
- unsigned v = c | 0x20; /* lowercase */
- v = v - '0';
+ unsigned v;
+
+ v = c - '0';
if (v <= 9)
return v;
- v = v + ('0' - 'a');
+ /* c | 0x20: letters to lower case, non-letters
+ * to (potentially different) non-letters */
+ v = (unsigned)(c | 0x20) - 'a';
if (v <= 5)
return v + 10;
return ~0;
}
/* For testing:
-void t(char c) { printf("'%c' %u\n", c, hex_to_bin(c)); }
-int main() { t('0'); t('9'); t('A'); t('F'); t('a'); t('f');
+void t(char c) { printf("'%c'(%u) %u\n", c, c, hex_to_bin(c)); }
+int main() { t(0x10); t(0x20); t('0'); t('9'); t('A'); t('F'); t('a'); t('f');
t('0'-1); t('9'+1); t('A'-1); t('F'+1); t('a'-1); t('f'+1); return 0; }
*/
static char *decodeString(char *orig, int option_d)
/* read config */
i = open_read_close("config", buf, sizeof(buf));
if (i < 0 && errno != ENOENT)
- bb_perror_msg(WARNING": %s/config", ld->name);
+ bb_perror_msg(WARNING"%s/config", ld->name);
if (i > 0) {
if (verbose)
bb_error_msg(INFO"read: %s/config", ld->name);
s = buf;
while (s) {
np = strchr(s, '\n');
- if (np) *np++ = '\0';
+ if (np)
+ *np++ = '\0';
switch (s[0]) {
case '+':
case '-':
case 'e':
case 'E':
+ /* Add '\n'-terminated line to ld->inst */
while (1) {
- int l = asprintf(&new, "%s%s\n", ld->inst?:"", s);
- if (l >= 0 && new) break;
+ int l = asprintf(&new, "%s%s\n", ld->inst ? : "", s);
+ if (l >= 0 && new)
+ break;
pause_nomem();
}
free(ld->inst);
s = ld->inst;
while (s) {
np = strchr(s, '\n');
- if (np) *np++ = '\0';
+ if (np)
+ *np++ = '\0';
s = np;
}
}
/* open current */
i = stat("current", &st);
if (i != -1) {
- if (st.st_size && ! (st.st_mode & S_IXUSR)) {
+ if (st.st_size && !(st.st_mode & S_IXUSR)) {
ld->fnsave[25] = '.';
ld->fnsave[26] = 'u';
ld->fnsave[27] = '\0';
rmoldest(ld);
i = -1;
} else {
- /* Be paranoid: st.st_size can be not just bigger, but WIDER! */
- /* (bug in original svlogd. remove this comment when fixed there) */
+ /* st.st_size can be not just bigger, but WIDER!
+ * This code is safe: if st.st_size > 4GB, we select
+ * ld->sizemax (because it's "unsigned") */
ld->size = (st.st_size > ld->sizemax) ? ld->sizemax : st.st_size;
}
} else {
int i;
input.fd = 0;
- input.events = POLLIN|POLLHUP|POLLERR;
+ input.events = POLLIN;
do {
if (rotateasap) {
return i;
}
-
static void sig_term_handler(int sig_no)
{
if (verbose)