| 797 | } |
| 798 | |
| 799 | static int get_next_char(struct config_source *cs) |
| 800 | { |
| 801 | int c = cs->do_fgetc(cs); |
| 802 | |
| 803 | if (c == '\r') { |
| 804 | /* DOS like systems */ |
| 805 | c = cs->do_fgetc(cs); |
| 806 | if (c != '\n') { |
| 807 | if (c != EOF) |
| 808 | cs->do_ungetc(c, cs); |
| 809 | c = '\r'; |
| 810 | } |
| 811 | } |
| 812 | |
| 813 | if (c != EOF && ++cs->total_len > INT_MAX) { |
| 814 | /* |
| 815 | * This is an absurdly long config file; refuse to parse |
| 816 | * further in order to protect downstream code from integer |
| 817 | * overflows. Note that we can't return an error specifically, |
| 818 | * but we can mark EOF and put trash in the return value, |
| 819 | * which will trigger a parse error. |
| 820 | */ |
| 821 | cs->eof = 1; |
| 822 | return 0; |
| 823 | } |
| 824 | |
| 825 | if (c == '\n') |
| 826 | cs->linenr++; |
| 827 | if (c == EOF) { |
| 828 | cs->eof = 1; |
| 829 | cs->linenr++; |
| 830 | c = '\n'; |
| 831 | } |
| 832 | return c; |
| 833 | } |
| 834 | |
| 835 | static char *parse_value(struct config_source *cs) |
| 836 | { |
no outgoing calls
no test coverage detected