Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 15835 | Differences between
and this patch

Collapse All | Expand All

(-)raidtools-1.00.3/lsraid.c.orig (-3 / +22 lines)
Lines 1031-1042 static int load_partitions(LSRContext *c Link Here
1031
{
1031
{
1032
    FILE *proc;
1032
    FILE *proc;
1033
    int major, minor, rc;
1033
    int major, minor, rc;
1034
    char line[MAX_LINE_LENGTH], name[MAX_LINE_LENGTH];
1034
    char name[MAX_LINE_LENGTH];
1035
    char *line = malloc(MAX_LINE_LENGTH);
1036
    char *current_read = malloc(MAX_LINE_LENGTH);
1035
    struct stat stat_buf;
1037
    struct stat stat_buf;
1036
1038
1037
    if (!ctxt || !ctxt->devtable)
1039
    if (!ctxt || !ctxt->devtable)
1038
        return(-EINVAL);
1040
        return(-EINVAL);
1039
1041
1042
    if (!line || !current_read)
1043
        return(-ENOMEM);
1044
1040
    /* Here we are in wonderful Hardcoded /proc Land */
1045
    /* Here we are in wonderful Hardcoded /proc Land */
1041
    proc = fopen("/proc/partitions", "r");
1046
    proc = fopen("/proc/partitions", "r");
1042
    if (!proc)
1047
    if (!proc)
Lines 1045-1052 static int load_partitions(LSRContext *c Link Here
1045
    while (1)
1050
    while (1)
1046
    {
1051
    {
1047
        rc = 0;
1052
        rc = 0;
1048
        if ((fgets(line, MAX_LINE_LENGTH, proc)) == NULL)
1053
1049
            break;
1054
        if ((fgets(current_read, MAX_LINE_LENGTH, proc)) == NULL)
1055
            goto out;
1056
        strcpy(line, (const char*) current_read);
1057
1058
        while (strlen(current_read) == (MAX_LINE_LENGTH-1))
1059
        {
1060
            int old_length = strlen(line);
1061
            line = realloc(line, old_length + MAX_LINE_LENGTH);
1062
            if ((fgets(current_read, MAX_LINE_LENGTH, proc)) == NULL)
1063
                goto out;
1064
            strcpy(line + old_length, current_read);
1065
        }
1050
1066
1051
        name[0] = 0;
1067
        name[0] = 0;
1052
        major = minor = 0;
1068
        major = minor = 0;
Lines 1100-1105 static int load_partitions(LSRContext *c Link Here
1100
        }
1116
        }
1101
    }
1117
    }
1102
1118
1119
 out:
1120
    free(current_read);
1121
    free(line);
1103
    fclose(proc);
1122
    fclose(proc);
1104
    return(rc);
1123
    return(rc);
1105
}  /* load_partitions() */
1124
}  /* load_partitions() */

Return to bug 15835