[PATCH v2 makedumpfile 1/3] Fix off by one error when checking cache_size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Given the test in write_cache():
	if (cd->buf_size < cd->cache_size)
		return TRUE;
a write is done if buf_size == cache_size.
The test at the beginning of write_kdump_page() intends to detect cases
when write_cache() will do a write, however it was missing this boundary
condition. This would lead write_kdump_page() to ignore errors from
write_cache().

Signed-off-by: Benjamin Poirier <bpoirier@xxxxxxxxxx>
---
 makedumpfile.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index fcb571f..aa05be7 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -7993,8 +7993,8 @@ write_kdump_page(struct cache_data *cd_header, struct cache_data *cd_page,
 	 * write the buffer cd_header into dumpfile and then write the cd_page.
 	 * With that, when enospc occurs, we can save more useful information.
 	 */
-	if (cd_header->buf_size + sizeof(*pd) > cd_header->cache_size
-		|| cd_page->buf_size + pd->size > cd_page->cache_size){
+	if (cd_header->buf_size + sizeof(*pd) >= cd_header->cache_size ||
+	    cd_page->buf_size + pd->size >= cd_page->cache_size) {
 		if( !write_cd_buf(cd_header) ) {
 			memset(cd_header->buf, 0, cd_header->cache_size);
 			write_cd_buf(cd_header);
-- 
2.32.0


_______________________________________________
kexec mailing list
kexec@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/kexec



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux