From 7a9c67ed287c3650e16512ed303fcbf33e0f714b Mon Sep 17 00:00:00 2001 From: Kjell Wooding Date: Sat, 12 Nov 2005 18:48:09 +0000 Subject: Paranoia. Check if last of a series of strlcats overflows. Pointed out by Han Boetes. --- usr.bin/mg/undo.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr.bin/mg/undo.c b/usr.bin/mg/undo.c index f65006f32dd..3938427c254 100644 --- a/usr.bin/mg/undo.c +++ b/usr.bin/mg/undo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: undo.c,v 1.32 2005/10/14 19:46:46 kjell Exp $ */ +/* $OpenBSD: undo.c,v 1.33 2005/11/12 18:48:08 kjell Exp $ */ /* * Copyright (c) 2002 Vincent Labrecque * All rights reserved. @@ -385,7 +385,10 @@ undo_dump(int f, int n) strlcat(buf, "\"", sizeof(buf)); } snprintf(tmp, sizeof(tmp), " [%d]", rec->region.r_size); - strlcat(buf, tmp, sizeof(buf)); + if (strlcat(buf, tmp, sizeof(buf)) >= sizeof(buf)) { + ewprintf("Undo record too large. Aborted."); + return (FALSE); + } addlinef(bp, "%s", buf); } return (TRUE); -- cgit v1.2.3