Merge branch 'jk/war-on-sprintf'
Many allocations that is manually counted (correctly) that are followed by strcpy/sprintf have been replaced with a less error prone constructs such as xstrfmt. Macintosh-specific breakage was noticed and corrected in this reroll. * jk/war-on-sprintf: (70 commits) name-rev: use strip_suffix to avoid magic numbers use strbuf_complete to conditionally append slash fsck: use for_each_loose_file_in_objdir Makefile: drop D_INO_IN_DIRENT build knob fsck: drop inode-sorting code convert strncpy to memcpy notes: document length of fanout path with a constant color: add color_set helper for copying raw colors prefer memcpy to strcpy help: clean up kfmclient munging receive-pack: simplify keep_arg computation avoid sprintf and strcpy with flex arrays use alloc_ref rather than hand-allocating "struct ref" color: add overflow checks for parsing colors drop strcpy in favor of raw sha1_to_hex use sha1_to_hex_r() instead of strcpy daemon: use cld->env_array when re-spawning stat_tracking_info: convert to argv_array http-push: use an argv_array for setup_revisions fetch-pack: use argv_array for index-pack / unpack-objects ...
This commit is contained in:
12
setup.c
12
setup.c
@ -99,10 +99,7 @@ char *prefix_path_gently(const char *prefix, int len,
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
sanitized = xmalloc(len + strlen(path) + 1);
|
||||
if (len)
|
||||
memcpy(sanitized, prefix, len);
|
||||
strcpy(sanitized + len, path);
|
||||
sanitized = xstrfmt("%.*s%s", len, prefix, path);
|
||||
if (remaining_prefix)
|
||||
*remaining_prefix = len;
|
||||
if (normalize_path_copy_len(sanitized, sanitized, remaining_prefix)) {
|
||||
@ -475,11 +472,8 @@ const char *read_gitfile_gently(const char *path, int *return_error_code)
|
||||
|
||||
if (!is_absolute_path(dir) && (slash = strrchr(path, '/'))) {
|
||||
size_t pathlen = slash+1 - path;
|
||||
size_t dirlen = pathlen + len - 8;
|
||||
dir = xmalloc(dirlen + 1);
|
||||
strncpy(dir, path, pathlen);
|
||||
strncpy(dir + pathlen, buf + 8, len - 8);
|
||||
dir[dirlen] = '\0';
|
||||
dir = xstrfmt("%.*s%.*s", (int)pathlen, path,
|
||||
(int)(len - 8), buf + 8);
|
||||
free(buf);
|
||||
buf = dir;
|
||||
}
|
||||
|
Reference in New Issue
Block a user