FreeBSD Bugzilla – Attachment 79440 Details for
Bug 114110
[libdisk] [patch] Disk_Names() returns a vector that is unsafe to free
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
file.txt
file.txt (text/plain), 1.30 KB, created by
David Sanderson
on 2007-06-28 22:50:01 UTC
(
hide
)
Description:
file.txt
Filename:
MIME Type:
Creator:
David Sanderson
Created:
2007-06-28 22:50:01 UTC
Size:
1.30 KB
patch
obsolete
>char ** >Disk_Names() >{ > static char **disks; > int error; > size_t listsize; > char *disklist; > char *disklistp; > size_t ndisks; > size_t i; > > error = sysctlbyname("kern.disks", NULL, &listsize, NULL, 0); > if (error) { > warn("kern.disks sysctl not available"); > return NULL; > } > > if (listsize == 0) > return (NULL); > > disklist = (char *)malloc(listsize + 1); > if (disklist == NULL) { > return NULL; > } > memset(disklist, 0, listsize + 1); > error = sysctlbyname("kern.disks", disklist, &listsize, NULL, 0); > if (error || disklist[0] == 0) { > free(disklist); > return NULL; > } > for (disklistp = disklist, ndisks = 0; disklistp;) { > char *disk = strsep(&disklistp, " "); > if (disk) { > /* We restore the space for a second pass through the names. */ > if (disklistp) { > disklistp[-1] = ' '; > } > ndisks++; > } > } > disks = malloc(sizeof *disks * (1 + ndisks)); > if (disks == NULL) { > free(disklist); > return NULL; > } > memset(disks,0,sizeof *disks * (1 + ndisks)); > for (disklistp = disklist, i = 0; i < ndisks; i++) { > disks[i] = strdup(strsep(&disklistp, " ")); > if (disks[i] == NULL) { > size_t j; > for (j = 0; j < i; j++) { > free(disks[j]); > } > free(disklist); > free(disks); > return NULL; > } > } > free(disklist); > qsort(disks, ndisks, sizeof(char*), qstrcmp); > return disks; >}
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 Raw
Actions:
View
Attachments on
bug 114110
: 79440