[07/15] tty: Check for valid index when collecting

Submitted by Cyrill Gorcunov on Sept. 7, 2018, 4:18 p.m.

Details

Message ID 20180907161836.25738-8-gorcunov@gmail.com
State New
Series "tty: Add support for multiple devtps instances"
Headers show

Commit Message

Cyrill Gorcunov Sept. 7, 2018, 4:18 p.m.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 criu/tty.c | 4 ++++
 1 file changed, 4 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/tty.c b/criu/tty.c
index 0f2a289d678a..a5b5a98e115b 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -1777,6 +1777,10 @@  static int collect_one_tty(void *obj, ProtobufCMessage *msg, struct cr_img *i)
 		info->tfe->has_mnt_id = true;
 		info->tfe->mnt_id = 0;
 	}
+	if (info->tfe->tty_info_id > ((MAX_TTYS << 1))) {
+		pr_err("Too big index %u\n", info->tfe->tty_info_id);
+		return -1;
+	}
 	list_add_tail(&info->list, &collected_ttys);
 	return 0;
 }