Commit 0fcd05631a1f59e156e613448262800c155e79d0

Patrick Steinhardt 2018-08-06T12:00:21

odb: fix use of wrong printf formatters The `git_odb_stream` members `declared_size` and `received_bytes` are both of the type `git_off_t`, which we usually defined to be a 64 bit signed integer. Thus, passing these members to "PRIdZ" formatters is not correct, as they are not guaranteed to accept big enough numbers. Instead, use the "PRId64" formatter, which is able to represent 64 bit signed integers.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/odb.c b/src/odb.c
index 919a951..f1c7ebc 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -1384,8 +1384,8 @@ static int git_odb_stream__invalid_length(
 {
 	giterr_set(GITERR_ODB,
 		"cannot %s - "
-		"Invalid length. %"PRIdZ" was expected. The "
-		"total size of the received chunks amounts to %"PRIdZ".",
+		"Invalid length. %"PRId64" was expected. The "
+		"total size of the received chunks amounts to %"PRId64".",
 		action, stream->declared_size, stream->received_bytes);
 
 	return -1;