git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e71c76f)
Don't call fwrite() with len == 0 when writing out relcache init file.
2022年3月23日 20:05:25 +0000 (13:05 -0700)
2022年3月23日 20:05:25 +0000 (13:05 -0700)
Noticed via -fsanitize=undefined.

Backpatch to all branches, for the same reasons as 46ab07ffda9.

Discussion: https://postgr.es/m/20220323173537.ll7klrglnp4gn2um@alap3.anarazel.de
Backpatch: 10-


diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index fbd11883e17b8dde702863ffab4972217e9f6f71..3d05297b0d9093d0bdda0bc729240226975f5d84 100644 (file)
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -6528,7 +6528,7 @@ write_item(const void *data, Size len, FILE *fp)
{
if (fwrite(&len, 1, sizeof(len), fp) != sizeof(len))
elog(FATAL, "could not write init file");
- if (fwrite(data, 1, len, fp) != len)
+ if (len > 0 && fwrite(data, 1, len, fp) != len)
elog(FATAL, "could not write init file");
}
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /