* [PATCH 1/1] RFC: git: update to v2.21.0-rc0
@ 2019-02-07 10:21 list
2019-02-07 10:57 ` john
0 siblings, 1 reply; 9+ messages in thread
From: list @ 2019-02-07 10:21 UTC (permalink / raw)
From: Christian Hesse <mail at eworm.de>
Update to git version v2.21.0-rc0. Required changes follow upstream commits:
* 6a7895fd8a3bd409f2b71ffc355d5142172cc2a0
(commit: prepare free_commit_buffer and release_commit_memory for
any repo)
* e092073d643b17c82d72cf692fbfaea9c9796f11
(tree.c: make read_tree*() take 'struct repository *')
* ace5707a803eda0f1dde3d776dc3729d3bc7759a
(banned.h: mark strncat() as banned)
Signed-off-by: Christian Hesse <mail at eworm.de>
---
Makefile | 4 ++--
git | 2 +-
ui-atom.c | 2 +-
ui-blame.c | 4 ++--
ui-blob.c | 9 ++++++---
ui-log.c | 4 ++--
ui-plain.c | 3 ++-
ui-ssdiff.c | 4 ++--
ui-stats.c | 2 +-
ui-tree.c | 10 ++++++----
10 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/Makefile b/Makefile
index e690c7f..080426c 100644
--- a/Makefile
+++ b/Makefile
@@ -14,8 +14,8 @@ htmldir = $(docdir)
pdfdir = $(docdir)
mandir = $(prefix)/share/man
SHA1_HEADER = <openssl/sha.h>
-GIT_VER = 2.20.0
-GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz
+GIT_VER = 2.21.0.rc0
+GIT_URL = https://www.kernel.org/pub/software/scm/git/testing/git-$(GIT_VER).tar.xz
INSTALL = install
COPYTREE = cp -r
MAN5_TXT = $(wildcard *.5.txt)
diff --git a/git b/git
index 5d826e9..d62dad7 160000
--- a/git
+++ b/git
@@ -1 +1 @@
-Subproject commit 5d826e972970a784bd7a7bdf587512510097b8c7
+Subproject commit d62dad7a7dca3f6a65162bf0e52cdf6927958e78
diff --git a/ui-atom.c b/ui-atom.c
index 3866823..c182fad 100644
--- a/ui-atom.c
+++ b/ui-atom.c
@@ -140,7 +140,7 @@ void cgit_print_atom(char *tip, char *path, int max_count)
}
while ((commit = get_revision(&rev)) != NULL) {
add_entry(commit, host);
- free_commit_buffer(commit);
+ free_commit_buffer(the_repository->parsed_objects, commit);
free_commit_list(commit->parents);
commit->parents = NULL;
}
diff --git a/ui-blame.c b/ui-blame.c
index c52cb9b..644c30a 100644
--- a/ui-blame.c
+++ b/ui-blame.c
@@ -290,8 +290,8 @@ void cgit_print_blame(void)
walk_tree_ctx.match_baselen = (path_items.match) ?
basedir_len(path_items.match) : -1;
- read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree,
- &walk_tree_ctx);
+ read_tree_recursive(the_repository, commit->maybe_tree, "", 0, 0,
+ &paths, walk_tree, &walk_tree_ctx);
if (!walk_tree_ctx.state)
cgit_print_error_page(404, "Not found", "Not found");
else if (walk_tree_ctx.state == 2)
diff --git a/ui-blob.c b/ui-blob.c
index 4b6b462..30e2d4b 100644
--- a/ui-blob.c
+++ b/ui-blob.c
@@ -56,7 +56,8 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only)
goto done;
if (oid_object_info(the_repository, &oid, &size) != OBJ_COMMIT)
goto done;
- read_tree_recursive(lookup_commit_reference(the_repository, &oid)->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+ read_tree_recursive(the_repository, lookup_commit_reference(the_repository, &oid)->maybe_tree,
+ "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
done:
free(path_items.match);
@@ -90,7 +91,8 @@ int cgit_print_file(char *path, const char *head, int file_only)
type = oid_object_info(the_repository, &oid, &size);
if (type == OBJ_COMMIT) {
commit = lookup_commit_reference(the_repository, &oid);
- read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+ read_tree_recursive(the_repository, commit->maybe_tree,
+ "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
if (!walk_tree_ctx.found_path)
return -1;
type = oid_object_info(the_repository, &oid, &size);
@@ -146,7 +148,8 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl
if ((!hex) && type == OBJ_COMMIT && path) {
commit = lookup_commit_reference(the_repository, &oid);
- read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+ read_tree_recursive(the_repository, commit->maybe_tree,
+ "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
type = oid_object_info(the_repository, &oid, &size);
}
diff --git a/ui-log.c b/ui-log.c
index 3bcb657..e91968b 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -488,7 +488,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; /* nop */) {
if (show_commit(commit, &rev))
i++;
- free_commit_buffer(commit);
+ free_commit_buffer(the_repository->parsed_objects, commit);
free_commit_list(commit->parents);
commit->parents = NULL;
}
@@ -510,7 +510,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
i++;
print_commit(commit, &rev);
}
- free_commit_buffer(commit);
+ free_commit_buffer(the_repository->parsed_objects, commit);
free_commit_list(commit->parents);
commit->parents = NULL;
}
diff --git a/ui-plain.c b/ui-plain.c
index 070c34b..b73c1cf 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -198,7 +198,8 @@ void cgit_print_plain(void)
}
else
walk_tree_ctx.match_baselen = basedir_len(path_items.match);
- read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+ read_tree_recursive(the_repository, commit->maybe_tree,
+ "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
if (!walk_tree_ctx.match)
cgit_print_error_page(404, "Not found", "Not found");
else if (walk_tree_ctx.match == 2)
diff --git a/ui-ssdiff.c b/ui-ssdiff.c
index c456033..1f12cfc 100644
--- a/ui-ssdiff.c
+++ b/ui-ssdiff.c
@@ -136,10 +136,10 @@ static char *replace_tabs(char *line)
for (;;) {
cur_buf = strchr(prev_buf, '\t');
if (!cur_buf) {
- strncat(result, prev_buf, result_len);
+ snprintf(result, result_len, "%s", prev_buf);
break;
} else {
- strncat(result, prev_buf, cur_buf - prev_buf);
+ snprintf(result, cur_buf - prev_buf, "%s", prev_buf);
linelen = strlen(result);
memset(&result[linelen], ' ', 8 - (linelen % 8));
result[linelen + 8 - (linelen % 8)] = '\0';
diff --git a/ui-stats.c b/ui-stats.c
index 7acd358..7272a61 100644
--- a/ui-stats.c
+++ b/ui-stats.c
@@ -241,7 +241,7 @@ static struct string_list collect_stats(const struct cgit_period *period)
memset(&authors, 0, sizeof(authors));
while ((commit = get_revision(&rev)) != NULL) {
add_commit(&authors, commit, period);
- free_commit_buffer(commit);
+ free_commit_buffer(the_repository->parsed_objects, commit);
free_commit_list(commit->parents);
commit->parents = NULL;
}
diff --git a/ui-tree.c b/ui-tree.c
index df8ad82..008fccc 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -185,8 +185,8 @@ static void write_tree_link(const struct object_id *oid, char *name,
tree_ctx.name = NULL;
tree_ctx.count = 0;
- read_tree_recursive(tree, "", 0, 1, &paths, single_tree_cb,
- &tree_ctx);
+ read_tree_recursive(the_repository, tree, "", 0, 1,
+ &paths, single_tree_cb, &tree_ctx);
if (tree_ctx.count != 1)
break;
@@ -294,7 +294,8 @@ static void ls_tree(const struct object_id *oid, char *path, struct walk_tree_co
}
ls_head();
- read_tree_recursive(tree, "", 0, 1, &paths, ls_item, walk_tree_ctx);
+ read_tree_recursive(the_repository, tree, "", 0, 1,
+ &paths, ls_item, walk_tree_ctx);
ls_tail();
}
@@ -373,7 +374,8 @@ void cgit_print_tree(const char *rev, char *path)
goto cleanup;
}
- read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+ read_tree_recursive(the_repository, commit->maybe_tree, "", 0, 0,
+ &paths, walk_tree, &walk_tree_ctx);
if (walk_tree_ctx.state == 1)
ls_tail();
else if (walk_tree_ctx.state == 2)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/1] RFC: git: update to v2.21.0-rc0
2019-02-07 10:21 [PATCH 1/1] RFC: git: update to v2.21.0-rc0 list
@ 2019-02-07 10:57 ` john
2019-02-08 21:48 ` [PATCH 1/2] ui-ssdiff: ban strncat() list
0 siblings, 1 reply; 9+ messages in thread
From: john @ 2019-02-07 10:57 UTC (permalink / raw)
On Thu, Feb 07, 2019 at 11:21:01AM +0100, Christian Hesse wrote:
> From: Christian Hesse <mail at eworm.de>
>
> Update to git version v2.21.0-rc0. Required changes follow upstream commits:
>
> * 6a7895fd8a3bd409f2b71ffc355d5142172cc2a0
> (commit: prepare free_commit_buffer and release_commit_memory for
> any repo)
>
> * e092073d643b17c82d72cf692fbfaea9c9796f11
> (tree.c: make read_tree*() take 'struct repository *')
>
> * ace5707a803eda0f1dde3d776dc3729d3bc7759a
> (banned.h: mark strncat() as banned)
Can we pull out the strncat changes and merge them in advance of the
version bump? I don't think there's any dependency on Git changes for
these.
> Signed-off-by: Christian Hesse <mail at eworm.de>
Even without the strncat changes pulled out, this looks sensible, so:
Reviewed-by: John Keeping <john at keeping.me.uk>
> ---
> Makefile | 4 ++--
> git | 2 +-
> ui-atom.c | 2 +-
> ui-blame.c | 4 ++--
> ui-blob.c | 9 ++++++---
> ui-log.c | 4 ++--
> ui-plain.c | 3 ++-
> ui-ssdiff.c | 4 ++--
> ui-stats.c | 2 +-
> ui-tree.c | 10 ++++++----
> 10 files changed, 25 insertions(+), 19 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index e690c7f..080426c 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -14,8 +14,8 @@ htmldir = $(docdir)
> pdfdir = $(docdir)
> mandir = $(prefix)/share/man
> SHA1_HEADER = <openssl/sha.h>
> -GIT_VER = 2.20.0
> -GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz
> +GIT_VER = 2.21.0.rc0
> +GIT_URL = https://www.kernel.org/pub/software/scm/git/testing/git-$(GIT_VER).tar.xz
> INSTALL = install
> COPYTREE = cp -r
> MAN5_TXT = $(wildcard *.5.txt)
> diff --git a/git b/git
> index 5d826e9..d62dad7 160000
> --- a/git
> +++ b/git
> @@ -1 +1 @@
> -Subproject commit 5d826e972970a784bd7a7bdf587512510097b8c7
> +Subproject commit d62dad7a7dca3f6a65162bf0e52cdf6927958e78
> diff --git a/ui-atom.c b/ui-atom.c
> index 3866823..c182fad 100644
> --- a/ui-atom.c
> +++ b/ui-atom.c
> @@ -140,7 +140,7 @@ void cgit_print_atom(char *tip, char *path, int max_count)
> }
> while ((commit = get_revision(&rev)) != NULL) {
> add_entry(commit, host);
> - free_commit_buffer(commit);
> + free_commit_buffer(the_repository->parsed_objects, commit);
> free_commit_list(commit->parents);
> commit->parents = NULL;
> }
> diff --git a/ui-blame.c b/ui-blame.c
> index c52cb9b..644c30a 100644
> --- a/ui-blame.c
> +++ b/ui-blame.c
> @@ -290,8 +290,8 @@ void cgit_print_blame(void)
> walk_tree_ctx.match_baselen = (path_items.match) ?
> basedir_len(path_items.match) : -1;
>
> - read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree,
> - &walk_tree_ctx);
> + read_tree_recursive(the_repository, commit->maybe_tree, "", 0, 0,
> + &paths, walk_tree, &walk_tree_ctx);
> if (!walk_tree_ctx.state)
> cgit_print_error_page(404, "Not found", "Not found");
> else if (walk_tree_ctx.state == 2)
> diff --git a/ui-blob.c b/ui-blob.c
> index 4b6b462..30e2d4b 100644
> --- a/ui-blob.c
> +++ b/ui-blob.c
> @@ -56,7 +56,8 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only)
> goto done;
> if (oid_object_info(the_repository, &oid, &size) != OBJ_COMMIT)
> goto done;
> - read_tree_recursive(lookup_commit_reference(the_repository, &oid)->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
> + read_tree_recursive(the_repository, lookup_commit_reference(the_repository, &oid)->maybe_tree,
> + "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
>
> done:
> free(path_items.match);
> @@ -90,7 +91,8 @@ int cgit_print_file(char *path, const char *head, int file_only)
> type = oid_object_info(the_repository, &oid, &size);
> if (type == OBJ_COMMIT) {
> commit = lookup_commit_reference(the_repository, &oid);
> - read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
> + read_tree_recursive(the_repository, commit->maybe_tree,
> + "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
> if (!walk_tree_ctx.found_path)
> return -1;
> type = oid_object_info(the_repository, &oid, &size);
> @@ -146,7 +148,8 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl
>
> if ((!hex) && type == OBJ_COMMIT && path) {
> commit = lookup_commit_reference(the_repository, &oid);
> - read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
> + read_tree_recursive(the_repository, commit->maybe_tree,
> + "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
> type = oid_object_info(the_repository, &oid, &size);
> }
>
> diff --git a/ui-log.c b/ui-log.c
> index 3bcb657..e91968b 100644
> --- a/ui-log.c
> +++ b/ui-log.c
> @@ -488,7 +488,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
> for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; /* nop */) {
> if (show_commit(commit, &rev))
> i++;
> - free_commit_buffer(commit);
> + free_commit_buffer(the_repository->parsed_objects, commit);
> free_commit_list(commit->parents);
> commit->parents = NULL;
> }
> @@ -510,7 +510,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
> i++;
> print_commit(commit, &rev);
> }
> - free_commit_buffer(commit);
> + free_commit_buffer(the_repository->parsed_objects, commit);
> free_commit_list(commit->parents);
> commit->parents = NULL;
> }
> diff --git a/ui-plain.c b/ui-plain.c
> index 070c34b..b73c1cf 100644
> --- a/ui-plain.c
> +++ b/ui-plain.c
> @@ -198,7 +198,8 @@ void cgit_print_plain(void)
> }
> else
> walk_tree_ctx.match_baselen = basedir_len(path_items.match);
> - read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
> + read_tree_recursive(the_repository, commit->maybe_tree,
> + "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
> if (!walk_tree_ctx.match)
> cgit_print_error_page(404, "Not found", "Not found");
> else if (walk_tree_ctx.match == 2)
> diff --git a/ui-ssdiff.c b/ui-ssdiff.c
> index c456033..1f12cfc 100644
> --- a/ui-ssdiff.c
> +++ b/ui-ssdiff.c
> @@ -136,10 +136,10 @@ static char *replace_tabs(char *line)
> for (;;) {
> cur_buf = strchr(prev_buf, '\t');
> if (!cur_buf) {
> - strncat(result, prev_buf, result_len);
> + snprintf(result, result_len, "%s", prev_buf);
> break;
> } else {
> - strncat(result, prev_buf, cur_buf - prev_buf);
> + snprintf(result, cur_buf - prev_buf, "%s", prev_buf);
> linelen = strlen(result);
> memset(&result[linelen], ' ', 8 - (linelen % 8));
> result[linelen + 8 - (linelen % 8)] = '\0';
> diff --git a/ui-stats.c b/ui-stats.c
> index 7acd358..7272a61 100644
> --- a/ui-stats.c
> +++ b/ui-stats.c
> @@ -241,7 +241,7 @@ static struct string_list collect_stats(const struct cgit_period *period)
> memset(&authors, 0, sizeof(authors));
> while ((commit = get_revision(&rev)) != NULL) {
> add_commit(&authors, commit, period);
> - free_commit_buffer(commit);
> + free_commit_buffer(the_repository->parsed_objects, commit);
> free_commit_list(commit->parents);
> commit->parents = NULL;
> }
> diff --git a/ui-tree.c b/ui-tree.c
> index df8ad82..008fccc 100644
> --- a/ui-tree.c
> +++ b/ui-tree.c
> @@ -185,8 +185,8 @@ static void write_tree_link(const struct object_id *oid, char *name,
> tree_ctx.name = NULL;
> tree_ctx.count = 0;
>
> - read_tree_recursive(tree, "", 0, 1, &paths, single_tree_cb,
> - &tree_ctx);
> + read_tree_recursive(the_repository, tree, "", 0, 1,
> + &paths, single_tree_cb, &tree_ctx);
>
> if (tree_ctx.count != 1)
> break;
> @@ -294,7 +294,8 @@ static void ls_tree(const struct object_id *oid, char *path, struct walk_tree_co
> }
>
> ls_head();
> - read_tree_recursive(tree, "", 0, 1, &paths, ls_item, walk_tree_ctx);
> + read_tree_recursive(the_repository, tree, "", 0, 1,
> + &paths, ls_item, walk_tree_ctx);
> ls_tail();
> }
>
> @@ -373,7 +374,8 @@ void cgit_print_tree(const char *rev, char *path)
> goto cleanup;
> }
>
> - read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
> + read_tree_recursive(the_repository, commit->maybe_tree, "", 0, 0,
> + &paths, walk_tree, &walk_tree_ctx);
> if (walk_tree_ctx.state == 1)
> ls_tail();
> else if (walk_tree_ctx.state == 2)
> _______________________________________________
> CGit mailing list
> CGit at lists.zx2c4.com
> https://lists.zx2c4.com/mailman/listinfo/cgit
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] ui-ssdiff: ban strncat()
2019-02-07 10:57 ` john
@ 2019-02-08 21:48 ` list
2019-02-09 11:31 ` Jason
2019-02-12 20:55 ` [PATCH v2 1/1] " list
0 siblings, 2 replies; 9+ messages in thread
From: list @ 2019-02-08 21:48 UTC (permalink / raw)
From: Christian Hesse <mail at eworm.de>
Git version v2.21.0 marks strncat() as banned (commit
ace5707a803eda0f1dde3d776dc3729d3bc7759a), so replace it.
Signed-off-by: Christian Hesse <mail at eworm.de>
Reviewed-by: John Keeping <john at keeping.me.uk>
---
ui-ssdiff.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ui-ssdiff.c b/ui-ssdiff.c
index c456033..1f12cfc 100644
--- a/ui-ssdiff.c
+++ b/ui-ssdiff.c
@@ -136,10 +136,10 @@ static char *replace_tabs(char *line)
for (;;) {
cur_buf = strchr(prev_buf, '\t');
if (!cur_buf) {
- strncat(result, prev_buf, result_len);
+ snprintf(result, result_len, "%s", prev_buf);
break;
} else {
- strncat(result, prev_buf, cur_buf - prev_buf);
+ snprintf(result, cur_buf - prev_buf, "%s", prev_buf);
linelen = strlen(result);
memset(&result[linelen], ' ', 8 - (linelen % 8));
result[linelen + 8 - (linelen % 8)] = '\0';
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] ui-ssdiff: ban strncat()
2019-02-08 21:48 ` [PATCH 1/2] ui-ssdiff: ban strncat() list
@ 2019-02-09 11:31 ` Jason
2019-02-10 13:08 ` list
2019-02-12 20:07 ` list
2019-02-12 20:55 ` [PATCH v2 1/1] " list
1 sibling, 2 replies; 9+ messages in thread
From: Jason @ 2019-02-09 11:31 UTC (permalink / raw)
You sure those statements are the same? Snprintf doesn't append like
strncat. Wouldn't strlcat be the more apt replacement?
--
Sent from my telephone.
On Fri, Feb 8, 2019, 22:49 Christian Hesse <list at eworm.de wrote:
> From: Christian Hesse <mail at eworm.de>
>
> Git version v2.21.0 marks strncat() as banned (commit
> ace5707a803eda0f1dde3d776dc3729d3bc7759a), so replace it.
>
> Signed-off-by: Christian Hesse <mail at eworm.de>
> Reviewed-by: John Keeping <john at keeping.me.uk>
> ---
> ui-ssdiff.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/ui-ssdiff.c b/ui-ssdiff.c
> index c456033..1f12cfc 100644
> --- a/ui-ssdiff.c
> +++ b/ui-ssdiff.c
> @@ -136,10 +136,10 @@ static char *replace_tabs(char *line)
> for (;;) {
> cur_buf = strchr(prev_buf, '\t');
> if (!cur_buf) {
> - strncat(result, prev_buf, result_len);
> + snprintf(result, result_len, "%s", prev_buf);
> break;
> } else {
> - strncat(result, prev_buf, cur_buf - prev_buf);
> + snprintf(result, cur_buf - prev_buf, "%s",
> prev_buf);
> linelen = strlen(result);
> memset(&result[linelen], ' ', 8 - (linelen % 8));
> result[linelen + 8 - (linelen % 8)] = '\0';
> _______________________________________________
> CGit mailing list
> CGit at lists.zx2c4.com
> https://lists.zx2c4.com/mailman/listinfo/cgit
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20190209/79257db3/attachment.html>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] ui-ssdiff: ban strncat()
2019-02-09 11:31 ` Jason
@ 2019-02-10 13:08 ` list
2019-02-12 20:07 ` list
1 sibling, 0 replies; 9+ messages in thread
From: list @ 2019-02-10 13:08 UTC (permalink / raw)
"Jason A. Donenfeld" <Jason at zx2c4.com> on Sat, 2019/02/09 12:31:
> You sure those statements are the same? Snprintf doesn't append like
> strncat. Wouldn't strlcat be the more apt replacement?
We have an unconditional
result[0] = '\0';
that mad be think it is safe. But we are inside a loop, so probably not... :-p
Let me have another look.
--
main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH"
"CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];)
putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20190210/73c9974b/attachment.asc>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] ui-ssdiff: ban strncat()
2019-02-09 11:31 ` Jason
2019-02-10 13:08 ` list
@ 2019-02-12 20:07 ` list
1 sibling, 0 replies; 9+ messages in thread
From: list @ 2019-02-12 20:07 UTC (permalink / raw)
"Jason A. Donenfeld" <Jason at zx2c4.com> on Sat, 2019/02/09 12:31:
> Wouldn't strlcat be the more apt replacement?
Looks like strlcat requires to link against libbsd. I do not think we
want that, no?
--
main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH"
"CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];)
putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20190212/4e37c506/attachment.asc>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/1] ui-ssdiff: ban strncat()
2019-02-08 21:48 ` [PATCH 1/2] ui-ssdiff: ban strncat() list
2019-02-09 11:31 ` Jason
@ 2019-02-12 20:55 ` list
2019-02-13 8:29 ` e
1 sibling, 1 reply; 9+ messages in thread
From: list @ 2019-02-12 20:55 UTC (permalink / raw)
From: Christian Hesse <mail at eworm.de>
Git version v2.21.0 marks strncat() as banned (commit
ace5707a803eda0f1dde3d776dc3729d3bc7759a), so replace it.
Signed-off-by: Christian Hesse <mail at eworm.de>
---
ui-ssdiff.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/ui-ssdiff.c b/ui-ssdiff.c
index c456033..a5892fb 100644
--- a/ui-ssdiff.c
+++ b/ui-ssdiff.c
@@ -117,7 +117,7 @@ static char *replace_tabs(char *line)
int n_tabs = 0;
int i;
char *result;
- int result_len;
+ size_t result_len;
if (linelen == 0) {
result = xmalloc(1);
@@ -136,10 +136,12 @@ static char *replace_tabs(char *line)
for (;;) {
cur_buf = strchr(prev_buf, '\t');
if (!cur_buf) {
- strncat(result, prev_buf, result_len);
+ linelen = strlen(result);
+ strlcpy(&result[linelen], prev_buf, result_len - linelen + 1);
break;
} else {
- strncat(result, prev_buf, cur_buf - prev_buf);
+ linelen = strlen(result);
+ strlcpy(&result[linelen], prev_buf, cur_buf - prev_buf + 1);
linelen = strlen(result);
memset(&result[linelen], ' ', 8 - (linelen % 8));
result[linelen + 8 - (linelen % 8)] = '\0';
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/1] ui-ssdiff: ban strncat()
2019-02-12 20:55 ` [PATCH v2 1/1] " list
@ 2019-02-13 8:29 ` e
2019-02-14 22:41 ` list
0 siblings, 1 reply; 9+ messages in thread
From: e @ 2019-02-13 8:29 UTC (permalink / raw)
Christian Hesse <list at eworm.de> wrote:
> From: Christian Hesse <mail at eworm.de>
>
> Git version v2.21.0 marks strncat() as banned (commit
> ace5707a803eda0f1dde3d776dc3729d3bc7759a), so replace it.
Btw, I posted a similar-in-spirit patch to replace strncat
in ui-ssdiff.c back in January: <20190102073710.580-1-e at 80x24.org>
It uses strbuf and is close to code which already exists in
git.git, so it doesn't make calls to strlen() repeatedly.
(I'm also responsible for strncat banning in git.git :)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/1] ui-ssdiff: ban strncat()
2019-02-13 8:29 ` e
@ 2019-02-14 22:41 ` list
0 siblings, 0 replies; 9+ messages in thread
From: list @ 2019-02-14 22:41 UTC (permalink / raw)
Eric Wong <e at 80x24.org> on Wed, 2019/02/13 08:29:
> Christian Hesse <list at eworm.de> wrote:
> > From: Christian Hesse <mail at eworm.de>
> >
> > Git version v2.21.0 marks strncat() as banned (commit
> > ace5707a803eda0f1dde3d776dc3729d3bc7759a), so replace it.
>
> Btw, I posted a similar-in-spirit patch to replace strncat
> in ui-ssdiff.c back in January: <20190102073710.580-1-e at 80x24.org>
>
> It uses strbuf and is close to code which already exists in
> git.git, so it doesn't make calls to strlen() repeatedly.
>
>
> (I'm also responsible for strncat banning in git.git :)
Ah, nice... I saw this but forgot about it. :-p
Jason, you are free to decide. ;)
--
main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH"
"CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];)
putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20190214/59a1a014/attachment.asc>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2019-02-14 22:41 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-07 10:21 [PATCH 1/1] RFC: git: update to v2.21.0-rc0 list
2019-02-07 10:57 ` john
2019-02-08 21:48 ` [PATCH 1/2] ui-ssdiff: ban strncat() list
2019-02-09 11:31 ` Jason
2019-02-10 13:08 ` list
2019-02-12 20:07 ` list
2019-02-12 20:55 ` [PATCH v2 1/1] " list
2019-02-13 8:29 ` e
2019-02-14 22:41 ` list
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).