File rarian-0.5.6-reg-parse-bugs.patch of Package rarian
--- rarian-0.6.0/librarian/rarian-reg-utils.c
+++ rarian-0.6.0/librarian/rarian-reg-utils.c
@@ -89,6 +89,10 @@
}
file = fopen (filename, "r");
+ if (!file) {
+ rrn_reg_free (reg);
+ return NULL;
+ }
buf = malloc (sizeof (char) * 1024);
while (fgets (buf, 1023, file)) {
@@ -607,13 +614,18 @@
char *tmp;
char *result = NULL;
tmp = strdup (buf);
- buf = fgets (buf, 1023, file);
- result = malloc (sizeof (char) * (strlen(tmp)+strlen(buf)+2));
+ if (fgets (buf, 1023, file)) {
+ result = malloc (sizeof (char) * 2048);
strcpy (result, tmp);
strcat (result, buf);
free (tmp);
free (buf);
- buf = result;
+ buf = result;
+ } else {
+ free (buf);
+ buf = realloc (tmp, sizeof (char) * 1024);
+ break;
+ }
}
real = buf;
while (*real && isspace(*real) && *real != '\n') {