Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 37610 Details for
Bug 15835
lsraid segfaults
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
longline-fix.patch
longline-fix.patch (text/plain), 1.79 KB, created by
Daniel Drake (RETIRED)
on 2004-08-17 09:43:29 UTC
(
hide
)
Description:
longline-fix.patch
Filename:
MIME Type:
Creator:
Daniel Drake (RETIRED)
Created:
2004-08-17 09:43:29 UTC
Size:
1.79 KB
patch
obsolete
>If /proc/partitions contains lines longer than MAX_LINE_LENGTH (default 100), >then a segfault is produced in most situations. This patch switches to more >dynamic memory allocation. > >- Daniel Drake <dsd@gentoo.org> > >--- raidtools-1.00.3/lsraid.c.orig 2004-08-17 18:09:55.648911352 +0100 >+++ raidtools-1.00.3/lsraid.c 2004-08-17 18:09:24.794601920 +0100 >@@ -1031,12 +1031,17 @@ static int load_partitions(LSRContext *c > { > FILE *proc; > int major, minor, rc; >- char line[MAX_LINE_LENGTH], name[MAX_LINE_LENGTH]; >+ char name[MAX_LINE_LENGTH]; >+ char *line = malloc(MAX_LINE_LENGTH); >+ char *current_read = malloc(MAX_LINE_LENGTH); > struct stat stat_buf; > > if (!ctxt || !ctxt->devtable) > return(-EINVAL); > >+ if (!line || !current_read) >+ return(-ENOMEM); >+ > /* Here we are in wonderful Hardcoded /proc Land */ > proc = fopen("/proc/partitions", "r"); > if (!proc) >@@ -1045,8 +1050,19 @@ static int load_partitions(LSRContext *c > while (1) > { > rc = 0; >- if ((fgets(line, MAX_LINE_LENGTH, proc)) == NULL) >- break; >+ >+ if ((fgets(current_read, MAX_LINE_LENGTH, proc)) == NULL) >+ goto out; >+ strcpy(line, (const char*) current_read); >+ >+ while (strlen(current_read) == (MAX_LINE_LENGTH-1)) >+ { >+ int old_length = strlen(line); >+ line = realloc(line, old_length + MAX_LINE_LENGTH); >+ if ((fgets(current_read, MAX_LINE_LENGTH, proc)) == NULL) >+ goto out; >+ strcpy(line + old_length, current_read); >+ } > > name[0] = 0; > major = minor = 0; >@@ -1100,6 +1116,9 @@ static int load_partitions(LSRContext *c > } > } > >+ out: >+ free(current_read); >+ free(line); > fclose(proc); > return(rc); > } /* load_partitions() */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 15835
:
37546
| 37610 |
37668