FrauBSD / pkgcenter

Package Center
Other
26 stars 4 forks source link

Fixup malloc sizes #1

Closed freebsdfrau closed 4 years ago

freebsdfrau commented 4 years ago

For malloc, we want to use the size of the string plus-one (for the terminating NUL byte).

Line 306 of dialog_util.c for example, we should malloc 11 bytes because length of "--progress" is 10, add one for NUL terminator (because C-strings are bound by an ASCII 0x0 at the end unlike, say, Pascal strings or P-strings, which have a length identifier at the beginning).

https://github.com/FrauBSD/pkgcenter/blob/c64aa1346c9b79e8f39b85a0f3880838da45ead2/depend/libdpv/dialog_util.c#L306-L308

At below line, need to malloc 12 for "--no-cancel":

https://github.com/FrauBSD/pkgcenter/blob/c64aa1346c9b79e8f39b85a0f3880838da45ead2/depend/libdpv/dialog_util.c#L310-L312

At below line, need to malloc 13 for "--auto-close":

https://github.com/FrauBSD/pkgcenter/blob/c64aa1346c9b79e8f39b85a0f3880838da45ead2/depend/libdpv/dialog_util.c#L314-L316

At below line, need to malloc 7 for "--text":

https://github.com/FrauBSD/pkgcenter/blob/c64aa1346c9b79e8f39b85a0f3880838da45ead2/depend/libdpv/dialog_util.c#L318-L320

At below line, need to malloc 9 for "--height":

https://github.com/FrauBSD/pkgcenter/blob/c64aa1346c9b79e8f39b85a0f3880838da45ead2/depend/libdpv/dialog_util.c#L328-L330

At below line, need to malloc 8 for "--width":

https://github.com/FrauBSD/pkgcenter/blob/c64aa1346c9b79e8f39b85a0f3880838da45ead2/depend/libdpv/dialog_util.c#L336-L338

freebsdfrau commented 4 years ago

👍