Do not allocate more than necessary
Review b10cba0e0af5b1e3e8cda0201d5563f085aab2a4 and 7a16f4582da2b854a0adcba445bf6f8d750b2919: * lib/groupio.c (merge_group_entries): Do not allocate more than necessary (sizeof char* instead of char). Thanks for Tomáš Mráz (alioth#313962) * lib/groupio.c (merge_group_entries): Document that new_members is correctly NULL terminated. (alioth:#313940) Align previous ChangeLog entries.
This commit is contained in:
parent
e8ab31d009
commit
0d66002c95
20
ChangeLog
20
ChangeLog
@ -1,3 +1,11 @@
|
|||||||
|
2013-08-04 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* lib/groupio.c (merge_group_entries): Do not allocate more than
|
||||||
|
necessary (sizeof char* instead of char).
|
||||||
|
Thanks for Tomáš Mráz (alioth#313962)
|
||||||
|
* lib/groupio.c (merge_group_entries): Document that new_members
|
||||||
|
is correctly NULL terminated. (alioth:#313940)
|
||||||
|
|
||||||
2013-08-03 Nicolas François <nicolas.francois@centraliens.net>
|
2013-08-03 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* Changelog: Update documentation of 2013-07-28 mancha entry.
|
* Changelog: Update documentation of 2013-07-28 mancha entry.
|
||||||
@ -48,13 +56,13 @@
|
|||||||
|
|
||||||
2013-07-29 Brad Hubbard <badone-guest@alioth.debian.org>
|
2013-07-29 Brad Hubbard <badone-guest@alioth.debian.org>
|
||||||
|
|
||||||
* lib/groupio.c: add newline char when two lines
|
* lib/groupio.c: add newline char when two lines
|
||||||
are concatenated
|
are concatenated
|
||||||
Closes: alioth#313942
|
Closes: alioth#313942
|
||||||
* lib/groupio.c: fix uninitialised memory in
|
* lib/groupio.c: fix uninitialised memory in
|
||||||
merge_group_entries causes segfault in useradd by changing
|
merge_group_entries causes segfault in useradd by changing
|
||||||
a call to malloc to a call to calloc
|
a call to malloc to a call to calloc
|
||||||
Closes: alioth:#313940
|
Closes: alioth:#313940
|
||||||
|
|
||||||
2013-07-28 Guido Trentalancia <guido@trentalancia.com>
|
2013-07-28 Guido Trentalancia <guido@trentalancia.com>
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ static /*@null@*/struct commonio_entry *merge_group_entries (
|
|||||||
|
|
||||||
/* Concatenate the 2 lines */
|
/* Concatenate the 2 lines */
|
||||||
new_line_len = strlen (gr1->line) + strlen (gr2->line) +2;
|
new_line_len = strlen (gr1->line) + strlen (gr2->line) +2;
|
||||||
new_line = (char *)malloc ((new_line_len + 1) * sizeof(char*));
|
new_line = (char *)malloc (new_line_len + 1);
|
||||||
if (NULL == new_line) {
|
if (NULL == new_line) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -362,6 +362,8 @@ static /*@null@*/struct commonio_entry *merge_group_entries (
|
|||||||
for (i=0; NULL != gptr1->gr_mem[i]; i++) {
|
for (i=0; NULL != gptr1->gr_mem[i]; i++) {
|
||||||
new_members[i] = gptr1->gr_mem[i];
|
new_members[i] = gptr1->gr_mem[i];
|
||||||
}
|
}
|
||||||
|
/* NULL termination enforced by above calloc */
|
||||||
|
|
||||||
members = i;
|
members = i;
|
||||||
for (i=0; NULL != gptr2->gr_mem[i]; i++) {
|
for (i=0; NULL != gptr2->gr_mem[i]; i++) {
|
||||||
char **pmember = new_members;
|
char **pmember = new_members;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user