public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* [PATCH setup] Don't write garbage into the "extrakeys" user setting
@ 2017-11-27 21:36 Ken Brown
  2017-11-27 22:20 ` Ken Brown
  2017-11-27 22:26 ` Jon Turney
  0 siblings, 2 replies; 6+ messages in thread
From: Ken Brown @ 2017-11-27 21:36 UTC (permalink / raw)
  To: cygwin-apps

The ExtraKeysSetting destructor called UserSettings::set() on a string
that was terminated by LF instead of NUL.  This led to garbage at the
end of the "extrakeys" setting that was written into setup.rc.  Fix
this by replacing the final LF by NUL before calling set().
---
 KeysSetting.cc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/KeysSetting.cc b/KeysSetting.cc
index a21c3c4..19c6df3 100644
--- a/KeysSetting.cc
+++ b/KeysSetting.cc
@@ -46,7 +46,11 @@ ExtraKeysSetting::ExtraKeysSetting ():
 ExtraKeysSetting::~ExtraKeysSetting ()
 {
   if (keybuffer)
-    UserSettings::instance().set ("extrakeys", keybuffer);
+    {
+      // Replace final LF with NUL.
+      keybuffer[bufsize - 1] = '\0';
+      UserSettings::instance().set ("extrakeys", keybuffer);
+    }
 }
 
 void
-- 
2.15.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-11-28 13:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-27 21:36 [PATCH setup] Don't write garbage into the "extrakeys" user setting Ken Brown
2017-11-27 22:20 ` Ken Brown
2017-11-28  2:14   ` Ken Brown
2017-11-28 12:58     ` Ken Brown
2017-11-28 13:59       ` Ken Brown
2017-11-27 22:26 ` Jon Turney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).