[lxc/lxc] fe444e: When an item is added to an array, then the array ...

0 views
Skip to first unread message

Wolfgang Bumiller

unread,
Jun 29, 2021, 2:54:55 AMJun 29
to lxc-...@lists.linuxcontainers.org
Branch: refs/heads/master
Home: https://github.com/lxc/lxc
Commit: fe444ea6bcfe65d58a4dc0bef0db0c3372ed12a5
https://github.com/lxc/lxc/commit/fe444ea6bcfe65d58a4dc0bef0db0c3372ed12a5
Author: Tomasz Blaszczak <tomasz.b...@consult.red>
Date: 2021-06-23 (Wed, 23 Jun 2021)

Changed paths:
M src/lxc/lxccontainer.c

Log Message:
-----------
When an item is added to an array, then the array is realloc()ed (to size+1),
and the item is copied (strdup()) to the array.
Thus, when an item is removed from an array, memory allocated for that item
should be freed, successive items should be left-shifted and the array
realloc()ed again (size-1).

Additional changes:
- If strdup() fails in add_to_array(), then an array should be
realloc()ed again to original size.
- Initialize an array in list_all_containers().

Signed-off-by: Tomasz Blaszczak <tomasz.b...@consult.red>


Commit: 5364ae41aaa4718853b41dd0d312555867b990f1
https://github.com/lxc/lxc/commit/5364ae41aaa4718853b41dd0d312555867b990f1
Author: Tomasz Blaszczak <tomasz.b...@consult.red>
Date: 2021-06-25 (Fri, 25 Jun 2021)

Changed paths:
M src/lxc/lxccontainer.c

Log Message:
-----------
Resize array in remove_from_array() and fix a crash

When an item is added to an array, then the array is realloc()ed (to size+1),
and the item is copied (strdup()) to the array.
Thus, when an item is removed from an array, allocated memory pointed by
the item (not the item itself) should be freed, successive items should
be left-shifted and the array realloc()ed again (size-1).

Additional changes:
- Initialize an array in list_all_containers().

Signed-off-by: Tomasz Blaszczak <tomasz.b...@consult.red>


Commit: bc5f0449c08cefeae97d3fadc6ec6df0f786d6f0
https://github.com/lxc/lxc/commit/bc5f0449c08cefeae97d3fadc6ec6df0f786d6f0
Author: Tomasz Blaszczak <tomasz.b...@consult.red>
Date: 2021-06-29 (Tue, 29 Jun 2021)

Changed paths:
M src/lxc/lxccontainer.c

Log Message:
-----------
When an item is added to an array, then the array is realloc()ed (to size+1),
and the item is copied (strdup()) to the array.
Thus, when an item is removed from an array, memory allocated for that item
should be freed, successive items should be left-shifted and the array
realloc()ed again (size-1).

Additional changes:
- If strdup() fails in add_to_array(), then an array should be
realloc()ed again to original size.
- Initialize an array in list_all_containers().

Signed-off-by: Tomasz Blaszczak <tomasz.b...@consult.red>


Commit: f1c64634c40a7218165538b89aca320fa258b3c1
https://github.com/lxc/lxc/commit/f1c64634c40a7218165538b89aca320fa258b3c1
Author: Wolfgang Bumiller <w.bum...@proxmox.com>
Date: 2021-06-29 (Tue, 29 Jun 2021)

Changed paths:
M src/lxc/lxccontainer.c

Log Message:
-----------
Merge pull request #3877 from tomasz-blaszczak-red/fix-crash-after-remove-from-array

remove_from_array() causes a crash


Compare: https://github.com/lxc/lxc/compare/5e3ec98927ac...f1c64634c40a
Reply all
Reply to author
Forward
0 new messages