Skip to content

Miscellaneous fixes from static analysis

John Keeping git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5notes-utils: handle boolean notes.rewritemode correctlynotes-utils.c+1 -15 replies
2/5utf8: fix iconv error detectionutf8.c+1 -10 replies
3/5utf8: use correct type for values in interval tableutf8.c+2 -20 replies
4/5builtin/mv: don't use memory after freebuiltin/mv.c+2 -10 replies
5/5streaming: simplify attaching a filterstreaming.c+1 -42 replies

Reviews trailers per patch

None of the 5 patches has a Reviewed-by or Acked-by.

PatchJohn Keeping
1/5
2/5
3/5
4/5
5/5Brought-to-attention-by

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/5] Miscellaneous fixes from static analysis

The first two of these fix real bugs, the rest just clean up some of the less obviously "not actually a problem" issues identified by Clang's static analyzer [1] and stack[2].

Stack is interesting in that it is designed to detect potentially undesirable optimizations where undefined behaviour may be being invoked unwittingly. It only detected two error's in git.git, the first of which is fixed by the final patch. The second it describes as:

	bug: anti-algebra
	model: |
	  %11 = icmp ult i8* %extra_args, %7, !dbg !342
	  -->  %10 = icmp slt i64 %9, 0, !dbg !342
	  ************************************************************
	  %extra_args <u ((sext i32 %buflen to i64) + %extra_args)<nsw>
	  -->  (-1 * (sext i32 %buflen to i64)) <s 0
	stack: 
	  - daemon.c:522:0
	ncore: 1
	core: 
	  - daemon.c:520:0
	    - pointer overflow

which shows that Clang has converted (simplifying from daemon.c:520):

	char *end = extra_args + buflen;
	if (extra_args < end)

into:

	if (buflen < 0)

This doesn't look like it can ever be subject to pointer overflow, so I have not considered the churn worth it here.

[1] http://clang-analyzer.llvm.org/
[2] https://github.com/xiw/stack

John Keeping (5):
notes-utils: handle boolean notes.rewritemode correctly
utf8: fix iconv error detection
utf8: use correct type for values in interval table builtin/mv: don't use memory after free
streaming: simplify attaching a filter

 builtin/mv.c  | 3 ++-
 notes-utils.c | 2 +-
 streaming.c   | 5 +----
 utf8.c        | 6 +++---
 4 files changed, 7 insertions(+), 9 deletions(-)
Signature · 1 line
1.9.rc0.187.g6292fff