mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-11 20:05:07 -05:00
Avoid a memmove by advancing value pointer
In packages, our description file contains: key = value is here type entries, and we passed "key " and " value is here" to our strtrim function, causing us to always memmove the value portion to remove the space. Since this is a throwaway buffer, do the advancing on our own before trimming to save the need to shift memory around; "value is here" will now be passed and strtrim will be responsible for trailing whitespace. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
56721c12ce
commit
06cbb516c3
@ -175,6 +175,7 @@ static int parse_descfile(struct archive *a, pmpkg_t *newpkg)
|
|||||||
newpkg->name ? newpkg->name : "error", linenum);
|
newpkg->name ? newpkg->name : "error", linenum);
|
||||||
} else {
|
} else {
|
||||||
key = _alpm_strtrim(key);
|
key = _alpm_strtrim(key);
|
||||||
|
while(*ptr == ' ') ptr++;
|
||||||
ptr = _alpm_strtrim(ptr);
|
ptr = _alpm_strtrim(ptr);
|
||||||
if(strcmp(key, "pkgname") == 0) {
|
if(strcmp(key, "pkgname") == 0) {
|
||||||
STRDUP(newpkg->name, ptr, RET_ERR(PM_ERR_MEMORY, -1));
|
STRDUP(newpkg->name, ptr, RET_ERR(PM_ERR_MEMORY, -1));
|
||||||
|
Loading…
Reference in New Issue
Block a user