Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 374899
Collapse All | Expand All

(-)a/src/librc/librc-misc.c (-3 / +1 lines)
Lines 70-79 rc_getline(char **line, size_t *len, FILE *fp) Link Here
70
		if (fgets(p, BUFSIZ, fp) == NULL)
70
		if (fgets(p, BUFSIZ, fp) == NULL)
71
			break;
71
			break;
72
		last += strlen(p);
72
		last += strlen(p);
73
		if (last && (*line)[last - 1] == '\n') {
73
		if (last)
74
			(*line)[last - 1] = '\0';
75
			break;
74
			break;
76
		}
77
	}
75
	}
78
	return last;
76
	return last;
79
}
77
}
(-)a/src/librc/librc.c (-2 / +12 lines)
Lines 771-785 rc_service_value_get(const char *service, const char *option) Link Here
771
	char *line = NULL;
771
	char *line = NULL;
772
	size_t len = 0;
772
	size_t len = 0;
773
	char file[PATH_MAX];
773
	char file[PATH_MAX];
774
	char *value = NULL;
774
775
775
	snprintf(file, sizeof(file), RC_SVCDIR "/options/%s/%s",
776
	snprintf(file, sizeof(file), RC_SVCDIR "/options/%s/%s",
776
	    service, option);
777
	    service, option);
777
	if ((fp = fopen(file, "r"))) {
778
	if ((fp = fopen(file, "r"))) {
778
		rc_getline(&line, &len, fp);
779
		while (rc_getline(&line, &len, fp)) {
780
			if (value == NULL) {
781
				value = (char *)xmalloc((len + 1) * sizeof(char));
782
				strncpy(value, line, (len + 1));
783
			}
784
			else {
785
				value = (char *)xrealloc(value, ((strlen(value) + len) * sizeof(char)));
786
				strncat(value, line, (len + 1));
787
			}
788
		}
779
		fclose(fp);
789
		fclose(fp);
780
	}
790
	}
781
791
782
	return line;
792
	return value;
783
}
793
}
784
librc_hidden_def(rc_service_value_get)
794
librc_hidden_def(rc_service_value_get)
785
795

Return to bug 374899