diff options
Diffstat (limited to 'runit/svlogd.c')
-rw-r--r-- | runit/svlogd.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/runit/svlogd.c b/runit/svlogd.c index b8fa5645b..6c8747e96 100644 --- a/runit/svlogd.c +++ b/runit/svlogd.c | |||
@@ -513,22 +513,25 @@ static unsigned logdir_open(struct logdir *ld, const char *fn) | |||
513 | /* read config */ | 513 | /* read config */ |
514 | i = open_read_close("config", buf, sizeof(buf)); | 514 | i = open_read_close("config", buf, sizeof(buf)); |
515 | if (i < 0 && errno != ENOENT) | 515 | if (i < 0 && errno != ENOENT) |
516 | bb_perror_msg(WARNING": %s/config", ld->name); | 516 | bb_perror_msg(WARNING"%s/config", ld->name); |
517 | if (i > 0) { | 517 | if (i > 0) { |
518 | if (verbose) | 518 | if (verbose) |
519 | bb_error_msg(INFO"read: %s/config", ld->name); | 519 | bb_error_msg(INFO"read: %s/config", ld->name); |
520 | s = buf; | 520 | s = buf; |
521 | while (s) { | 521 | while (s) { |
522 | np = strchr(s, '\n'); | 522 | np = strchr(s, '\n'); |
523 | if (np) *np++ = '\0'; | 523 | if (np) |
524 | *np++ = '\0'; | ||
524 | switch (s[0]) { | 525 | switch (s[0]) { |
525 | case '+': | 526 | case '+': |
526 | case '-': | 527 | case '-': |
527 | case 'e': | 528 | case 'e': |
528 | case 'E': | 529 | case 'E': |
530 | /* Add '\n'-terminated line to ld->inst */ | ||
529 | while (1) { | 531 | while (1) { |
530 | int l = asprintf(&new, "%s%s\n", ld->inst?:"", s); | 532 | int l = asprintf(&new, "%s%s\n", ld->inst ? : "", s); |
531 | if (l >= 0 && new) break; | 533 | if (l >= 0 && new) |
534 | break; | ||
532 | pause_nomem(); | 535 | pause_nomem(); |
533 | } | 536 | } |
534 | free(ld->inst); | 537 | free(ld->inst); |
@@ -578,7 +581,8 @@ static unsigned logdir_open(struct logdir *ld, const char *fn) | |||
578 | s = ld->inst; | 581 | s = ld->inst; |
579 | while (s) { | 582 | while (s) { |
580 | np = strchr(s, '\n'); | 583 | np = strchr(s, '\n'); |
581 | if (np) *np++ = '\0'; | 584 | if (np) |
585 | *np++ = '\0'; | ||
582 | s = np; | 586 | s = np; |
583 | } | 587 | } |
584 | } | 588 | } |
@@ -586,7 +590,7 @@ static unsigned logdir_open(struct logdir *ld, const char *fn) | |||
586 | /* open current */ | 590 | /* open current */ |
587 | i = stat("current", &st); | 591 | i = stat("current", &st); |
588 | if (i != -1) { | 592 | if (i != -1) { |
589 | if (st.st_size && ! (st.st_mode & S_IXUSR)) { | 593 | if (st.st_size && !(st.st_mode & S_IXUSR)) { |
590 | ld->fnsave[25] = '.'; | 594 | ld->fnsave[25] = '.'; |
591 | ld->fnsave[26] = 'u'; | 595 | ld->fnsave[26] = 'u'; |
592 | ld->fnsave[27] = '\0'; | 596 | ld->fnsave[27] = '\0'; |
@@ -600,8 +604,9 @@ static unsigned logdir_open(struct logdir *ld, const char *fn) | |||
600 | rmoldest(ld); | 604 | rmoldest(ld); |
601 | i = -1; | 605 | i = -1; |
602 | } else { | 606 | } else { |
603 | /* Be paranoid: st.st_size can be not just bigger, but WIDER! */ | 607 | /* st.st_size can be not just bigger, but WIDER! |
604 | /* (bug in original svlogd. remove this comment when fixed there) */ | 608 | * This code is safe: if st.st_size > 4GB, we select |
609 | * ld->sizemax (because it's "unsigned") */ | ||
605 | ld->size = (st.st_size > ld->sizemax) ? ld->sizemax : st.st_size; | 610 | ld->size = (st.st_size > ld->sizemax) ? ld->sizemax : st.st_size; |
606 | } | 611 | } |
607 | } else { | 612 | } else { |
@@ -667,7 +672,7 @@ static int buffer_pread(int fd, char *s, unsigned len) | |||
667 | int i; | 672 | int i; |
668 | 673 | ||
669 | input.fd = 0; | 674 | input.fd = 0; |
670 | input.events = POLLIN|POLLHUP|POLLERR; | 675 | input.events = POLLIN; |
671 | 676 | ||
672 | do { | 677 | do { |
673 | if (rotateasap) { | 678 | if (rotateasap) { |
@@ -744,7 +749,6 @@ static int buffer_pread(int fd, char *s, unsigned len) | |||
744 | return i; | 749 | return i; |
745 | } | 750 | } |
746 | 751 | ||
747 | |||
748 | static void sig_term_handler(int sig_no) | 752 | static void sig_term_handler(int sig_no) |
749 | { | 753 | { |
750 | if (verbose) | 754 | if (verbose) |