[mw-devel] [Git][arthur/mw][master] Fix strncpy length in add_mesg

Andrew Price welshbyte at sucs.org
Fri Oct 21 16:29:56 BST 2016


Andrew Price pushed to branch master at Justin Mitchell / mw


Commits:
36f78f8e by Andrew Price at 2016-10-21T16:29:50+01:00
Fix strncpy length in add_mesg

Fixes:

  talk{0}-* !w
  Writing in folder Foo.
  Message from andy
  *** buffer overflow detected ***: /home/andy/src/mw/src/client/mw
  terminated

- - - - -


1 changed file:

- src/client/add.c


Changes:

=====================================
src/client/add.c
=====================================
--- a/src/client/add.c
+++ b/src/client/add.c
@@ -189,7 +189,9 @@ int add_msg(int folnum, struct user *user, int replyto)
 
 	new->date=time(0);
 	if (!remote) printf(_("Message from %s\n"), user->record.name);
-	strncpy(new->from, user->record.name, 30);
+	strncpy(new->from, user->record.name, NAMESIZE);
+	new->from[NAMESIZE] = '\0';
+
 	if (replyto==0)
 	{
 		char t[NAMESIZE+1];



View it on GitLab: https://projects.sucs.org/arthur/mw/commit/36f78f8e4c9e242d32dd7f90ca4bc64bbb818576
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/mw-devel/attachments/20161021/49a2cdcd/attachment.html>


More information about the mw-devel mailing list