[Ada] Address warning compiling terminals.c
authorArnaud Charlet <charlet@adacore.com>
Wed, 11 Nov 2020 16:31:27 +0000 (11:31 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 30 Nov 2020 14:16:18 +0000 (09:16 -0500)
gcc/ada/

* terminals.c (allocate_pty_desc): Copy one less byte since the
last byte will always be set to 0.

gcc/ada/terminals.c

index 81388a7771b8c99eb730c96c07755cc4794927c9..ec9db3a6a4c647a665f63d731c2fb4c6695602bc 100644 (file)
@@ -1244,7 +1244,7 @@ allocate_pty_desc (pty_desc **desc) {
   result->slave_fd   = slave_fd;
   /* the string returned by ptsname or _getpty is a static allocated string. So
      we should make a copy */
-  strncpy (result->slave_name, slave_name, sizeof (result->slave_name));
+  strncpy (result->slave_name, slave_name, sizeof (result->slave_name) - 1);
   result->slave_name[sizeof (result->slave_name) - 1] = '\0';
   result->child_pid  = -1;
   *desc=result;