guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 03/33: Merge from stable-2.2


From: Andy Wingo
Subject: [Guile-commits] 03/33: Merge from stable-2.2
Date: Fri, 2 Aug 2019 09:38:24 -0400 (EDT)

wingo pushed a commit to branch master
in repository guile.

commit afb2c9624884b6705b760a80ecfd823b27d828d5
Merge: 6a10220 91ba73b
Author: Andy Wingo <address@hidden>
Date:   Fri Aug 2 14:37:55 2019 +0200

    Merge from stable-2.2

 libguile/bytevectors.c |  27 ++++++++-----
 libguile/fports.c      |   7 +++-
 libguile/guardians.c   |   4 +-
 libguile/ports.c       |  15 +++----
 libguile/r6rs-ports.c  | 104 ++++++++++++++++++++++++++++++-------------------
 libguile/strings.c     |  20 ++++++++--
 libguile/strports.c    |  29 ++++++++++----
 libguile/vectors.c     |   4 +-
 8 files changed, 139 insertions(+), 71 deletions(-)

diff --cc libguile/fports.c
index 9aa2ea9,5de08d3..b9b16f3
--- a/libguile/fports.c
+++ b/libguile/fports.c
@@@ -1,21 -1,21 +1,21 @@@
- /* Copyright 1995-2004,2006-2015,2017-2018
 -/* Copyright (C) 1995-2004, 2006-2015, 2017, 2019
 - *   Free Software Foundation, Inc.
 - *
 - * This library is free software; you can redistribute it and/or
 - * modify it under the terms of the GNU Lesser General Public License
 - * as published by the Free Software Foundation; either version 3 of
 - * the License, or (at your option) any later version.
 - *
 - * This library is distributed in the hope that it will be useful, but
 - * WITHOUT ANY WARRANTY; without even the implied warranty of
 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 - * Lesser General Public License for more details.
 - *
 - * You should have received a copy of the GNU Lesser General Public
 - * License along with this library; if not, write to the Free Software
 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 - * 02110-1301 USA
 - */
++/* Copyright 1995-2004,2006-2015,2017-2019
 +     Free Software Foundation, Inc.
 +
 +   This file is part of Guile.
 +
 +   Guile is free software: you can redistribute it and/or modify it
 +   under the terms of the GNU Lesser General Public License as published
 +   by the Free Software Foundation, either version 3 of the License, or
 +   (at your option) any later version.
 +
 +   Guile is distributed in the hope that it will be useful, but WITHOUT
 +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 +   License for more details.
 +
 +   You should have received a copy of the GNU Lesser General Public
 +   License along with Guile.  If not, see
 +   <https://www.gnu.org/licenses/>.  */
  
  
  
diff --cc libguile/guardians.c
index 7620f4d,2c63b58..fa8c8b8
--- a/libguile/guardians.c
+++ b/libguile/guardians.c
@@@ -1,21 -1,21 +1,21 @@@
- /* Copyright 1998-2001,2006,2008-2009,2011-2013,2018
 -/* Copyright (C) 1998-2001, 2006, 2008, 2009, 2011-2013, 2019
 - *   Free Software Foundation, Inc.
 - *
 - * This library is free software; you can redistribute it and/or
 - * modify it under the terms of the GNU Lesser General Public License
 - * as published by the Free Software Foundation; either version 3 of
 - * the License, or (at your option) any later version.
 - *
 - * This library is distributed in the hope that it will be useful, but
 - * WITHOUT ANY WARRANTY; without even the implied warranty of
 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 - * Lesser General Public License for more details.
 - *
 - * You should have received a copy of the GNU Lesser General Public
 - * License along with this library; if not, write to the Free Software
 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 - * 02110-1301 USA
 - */
++/* Copyright 1998-2001,2006,2008-2009,2011-2013,2018-2019
 +     Free Software Foundation, Inc.
 +
 +   This file is part of Guile.
 +
 +   Guile is free software: you can redistribute it and/or modify it
 +   under the terms of the GNU Lesser General Public License as published
 +   by the Free Software Foundation, either version 3 of the License, or
 +   (at your option) any later version.
 +
 +   Guile is distributed in the hope that it will be useful, but WITHOUT
 +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 +   License for more details.
 +
 +   You should have received a copy of the GNU Lesser General Public
 +   License along with Guile.  If not, see
 +   <https://www.gnu.org/licenses/>.  */
  
  
  /* This is an implementation of guardians as described in
diff --cc libguile/ports.c
index 0ec4c14,900de67..f64152b
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@@ -1,21 -1,21 +1,21 @@@
- /* Copyright 1995-2001,2003-2004,2006-2018
 -/* Copyright (C) 1995-2001, 2003-2004, 2006-2017, 2019
 - *   Free Software Foundation, Inc.
 - *
 - * This library is free software; you can redistribute it and/or
 - * modify it under the terms of the GNU Lesser General Public License
 - * as published by the Free Software Foundation; either version 3 of
 - * the License, or (at your option) any later version.
 - *
 - * This library is distributed in the hope that it will be useful, but
 - * WITHOUT ANY WARRANTY; without even the implied warranty of
 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 - * Lesser General Public License for more details.
 - *
 - * You should have received a copy of the GNU Lesser General Public
 - * License along with this library; if not, write to the Free Software
 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 - * 02110-1301 USA
 - */
++/* Copyright 1995-2001,2003-2004,2006-2019
 +     Free Software Foundation, Inc.
 +
 +   This file is part of Guile.
 +
 +   Guile is free software: you can redistribute it and/or modify it
 +   under the terms of the GNU Lesser General Public License as published
 +   by the Free Software Foundation, either version 3 of the License, or
 +   (at your option) any later version.
 +
 +   Guile is distributed in the hope that it will be useful, but WITHOUT
 +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 +   License for more details.
 +
 +   You should have received a copy of the GNU Lesser General Public
 +   License along with Guile.  If not, see
 +   <https://www.gnu.org/licenses/>.  */
  
  
  
diff --cc libguile/r6rs-ports.c
index 4334f5c,90387e8..255ba62
--- a/libguile/r6rs-ports.c
+++ b/libguile/r6rs-ports.c
@@@ -1,48 -1,42 +1,49 @@@
- /* Copyright 2009-2011,2013-2015,2018
 -/* Copyright (C) 2009-2011, 2013-2015, 2018, 2019
 - *   Free Software Foundation, Inc.
 - *
 - * This library is free software; you can redistribute it and/or
 - * modify it under the terms of the GNU Lesser General Public License
 - * as published by the Free Software Foundation; either version 3 of
 - * the License, or (at your option) any later version.
 - *
 - * This library is distributed in the hope that it will be useful, but
 - * WITHOUT ANY WARRANTY; without even the implied warranty of
 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 - * Lesser General Public License for more details.
 - *
 - * You should have received a copy of the GNU Lesser General Public
 - * License along with this library; if not, write to the Free Software
 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 - * 02110-1301 USA
 - */
++/* Copyright 2009-2011,2013-2015,2018-2019
 +     Free Software Foundation, Inc.
 +
 +   This file is part of Guile.
 +
 +   Guile is free software: you can redistribute it and/or modify it
 +   under the terms of the GNU Lesser General Public License as published
 +   by the Free Software Foundation, either version 3 of the License, or
 +   (at your option) any later version.
 +
 +   Guile is distributed in the hope that it will be useful, but WITHOUT
 +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 +   License for more details.
 +
 +   You should have received a copy of the GNU Lesser General Public
 +   License along with Guile.  If not, see
 +   <https://www.gnu.org/licenses/>.  */
  
  #ifdef HAVE_CONFIG_H
  # include <config.h>
  #endif
  
++#include <assert.h>
++#include <intprops.h>
  #include <unistd.h>
  #include <string.h>
  #include <stdio.h>
--#include <assert.h>
 -#include <intprops.h>
 -
 -#include "libguile/_scm.h"
 -#include "libguile/bytevectors.h"
 -#include "libguile/chars.h"
 -#include "libguile/eval.h"
 -#include "libguile/r6rs-ports.h"
 -#include "libguile/strings.h"
 -#include "libguile/validate.h"
 -#include "libguile/values.h"
 -#include "libguile/vectors.h"
 -#include "libguile/ports-internal.h"
 +#include "boolean.h"
 +#include "bytevectors.h"
 +#include "chars.h"
 +#include "eval.h"
 +#include "extensions.h"
 +#include "gsubr.h"
 +#include "numbers.h"
 +#include "ports-internal.h"
 +#include "procs.h"
 +#include "smob.h"
 +#include "strings.h"
 +#include "symbols.h"
 +#include "syscalls.h"
 +#include "values.h"
 +#include "vectors.h"
 +#include "version.h"
 +
 +#include "r6rs-ports.h"
  
  
  
@@@ -723,6 -725,6 +732,8 @@@ bytevector_output_port_buffer_init (scm
    /* Don't clear the port.  */
  }
  
++#define MAX(A, B) ((A) >= (B) ? (A) : (B))
++
  static inline void
  bytevector_output_port_buffer_grow (scm_t_bytevector_output_port_buffer *buf,
                                      size_t min_size)
@@@ -730,17 -732,20 +741,20 @@@
    char *new_buf;
    size_t new_size;
  
-   for (new_size = buf->total_len
-        ? buf->total_len : SCM_BYTEVECTOR_OUTPUT_PORT_BUFFER_INITIAL_SIZE;
-        new_size < min_size;
-        new_size *= 2);
- 
    if (buf->buffer)
-     new_buf = scm_gc_realloc ((void *) buf->buffer, buf->total_len,
-                             new_size, SCM_GC_BYTEVECTOR_OUTPUT_PORT);
+     {
+       if (INT_ADD_OVERFLOW (buf->total_len, buf->total_len))
+         scm_num_overflow ("bytevector_output_port_buffer_grow");
 -      new_size = max (min_size, buf->total_len * 2);
++      new_size = MAX (min_size, buf->total_len * 2);
+       new_buf = scm_gc_realloc ((void *) buf->buffer, buf->total_len,
+                                 new_size, SCM_GC_BYTEVECTOR_OUTPUT_PORT);
+     }
    else
-     new_buf = scm_gc_malloc_pointerless (new_size,
-                                          SCM_GC_BYTEVECTOR_OUTPUT_PORT);
+     {
 -      new_size = max (min_size, 
SCM_BYTEVECTOR_OUTPUT_PORT_BUFFER_INITIAL_SIZE);
++      new_size = MAX (min_size, 
SCM_BYTEVECTOR_OUTPUT_PORT_BUFFER_INITIAL_SIZE);
+       new_buf = scm_gc_malloc_pointerless (new_size,
+                                            SCM_GC_BYTEVECTOR_OUTPUT_PORT);
+     }
  
    buf->buffer = new_buf;
    buf->total_len = new_size;
diff --cc libguile/strings.c
index 8f6a47e,9497a3f..57c1b0c
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@@ -32,23 -31,20 +32,24 @@@
  #include <unistr.h>
  #include <uniconv.h>
  #include <c-strcase.h>
+ #include <intprops.h>
  
 +#include "chars.h"
 +#include "deprecation.h"
 +#include "error.h"
 +#include "generalized-vectors.h"
 +#include "gsubr.h"
 +#include "numbers.h"
 +#include "pairs.h"
 +#include "ports-internal.h"
 +#include "ports.h"
 +#include "private-options.h"
  #include "striconveh.h"
 +#include "symbols.h"
 +#include "threads.h"
 +
 +#include "strings.h"
  
 -#include "libguile/_scm.h"
 -#include "libguile/chars.h"
 -#include "libguile/strings.h"
 -#include "libguile/ports.h"
 -#include "libguile/ports-internal.h"
 -#include "libguile/error.h"
 -#include "libguile/generalized-vectors.h"
 -#include "libguile/deprecation.h"
 -#include "libguile/validate.h"
 -#include "libguile/private-options.h"
  
  #ifndef SCM_MAX_ALLOCA
  # define SCM_MAX_ALLOCA 4096 /* Max bytes per string to allocate via alloca */
@@@ -155,9 -157,16 +162,16 @@@ make_wide_stringbuf (size_t len
      lenhist[1000]++;
  #endif
  
+   /* Make sure that the total allocation size will not overflow size_t,
+      with ~30 extra bytes to spare to avoid an overflow within the
+      allocator.  */
+   if (len > (((size_t) -(STRINGBUF_HEADER_BYTES + 32 + sizeof (scm_t_wchar)))
+              / sizeof (scm_t_wchar)))
+     scm_num_overflow ("make_wide_stringbuf");
 -    
++
    raw_len = (len + 1) * sizeof (scm_t_wchar);
    buf = SCM_PACK_POINTER (scm_gc_malloc_pointerless (STRINGBUF_HEADER_BYTES + 
raw_len,
-                                           "string"));
+                                                      "string"));
  
    SCM_SET_CELL_TYPE (buf, STRINGBUF_TAG | STRINGBUF_F_WIDE);
    SCM_SET_CELL_WORD_1 (buf, (scm_t_bits) len);
diff --cc libguile/strports.c
index a9bcdc2,876a62a..821a04c
--- a/libguile/strports.c
+++ b/libguile/strports.c
@@@ -24,28 -24,27 +24,29 @@@
  #  include <config.h>
  #endif
  
 -#include "libguile/_scm.h"
 -
  #include <stdio.h>
 +#include <string.h>
  #include <unistd.h>
+ #include <intprops.h>
  
 -#include "libguile/bytevectors.h"
 -#include "libguile/eval.h"
 -#include "libguile/ports.h"
 -#include "libguile/read.h"
 -#include "libguile/strings.h"
 -#include "libguile/modules.h"
 -#include "libguile/validate.h"
 -#include "libguile/deprecation.h"
 -#include "libguile/srfi-4.h"
 +#include "bytevectors.h"
 +#include "deprecation.h"
 +#include "eval.h"
 +#include "gsubr.h"
 +#include "keywords.h"
 +#include "modules.h"
 +#include "ports.h"
 +#include "procs.h"
 +#include "read.h"
 +#include "srfi-4.h"
 +#include "strings.h"
 +#include "symbols.h"
 +#include "syscalls.h"
 +#include "threads.h"
 +#include "variable.h"
 +
 +#include "strports.h"
  
 -#include "libguile/strports.h"
 -
 -#ifdef HAVE_STRING_H
 -#include <string.h>
 -#endif
  
  
  
@@@ -82,20 -81,23 +83,25 @@@ string_port_read (SCM port, SCM dst, si
    return count;
  }
  
 +#define MAX(A, B) ((A) >= (B) ? (A) : (B))
 +
  static size_t
  string_port_write (SCM port, SCM src, size_t start, size_t count)
+ #define FUNC_NAME "string_port_write"
  {
    struct string_port *stream = (void *) SCM_STREAM (port);
+   size_t old_size = SCM_BYTEVECTOR_LENGTH (stream->bytevector);
  
-   if (SCM_BYTEVECTOR_LENGTH (stream->bytevector) < stream->pos + count)
+   if (count > old_size - stream->pos)
      {
        SCM new_bv;
        size_t new_size;
  
-       new_size = MAX (SCM_BYTEVECTOR_LENGTH (stream->bytevector) * 2,
-                       stream->pos + count);
+       if (INT_ADD_OVERFLOW (stream->pos, count))
+         scm_num_overflow (FUNC_NAME);
+ 
+       /* If (old_size * 2) overflows, it's harmless.  */
 -      new_size = max (old_size * 2, stream->pos + count);
++      new_size = MAX (old_size * 2, stream->pos + count);
        new_bv = scm_c_make_bytevector (new_size);
        memcpy (SCM_BYTEVECTOR_CONTENTS (new_bv),
                SCM_BYTEVECTOR_CONTENTS (stream->bytevector),
diff --cc libguile/vectors.c
index e716e52,acdda5d..87a50a3
--- a/libguile/vectors.c
+++ b/libguile/vectors.c
@@@ -1,21 -1,21 +1,21 @@@
- /* Copyright 1995-1996,1998-2001,2006,2008-2012,2014,2018
 -/* Copyright (C) 1995, 1996, 1998-2001, 2006, 2008-2012, 2014, 2019
 - *   Free Software Foundation, Inc.
 - *
 - * This library is free software; you can redistribute it and/or
 - * modify it under the terms of the GNU Lesser General Public License
 - * as published by the Free Software Foundation; either version 3 of
 - * the License, or (at your option) any later version.
 - *
 - * This library is distributed in the hope that it will be useful, but
 - * WITHOUT ANY WARRANTY; without even the implied warranty of
 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 - * Lesser General Public License for more details.
 - *
 - * You should have received a copy of the GNU Lesser General Public
 - * License along with this library; if not, write to the Free Software
 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 - * 02110-1301 USA
 - */
++/* Copyright 1995-1996,1998-2001,2006,2008-2012,2014,2018-2019
 +     Free Software Foundation, Inc.
 +
 +   This file is part of Guile.
 +
 +   Guile is free software: you can redistribute it and/or modify it
 +   under the terms of the GNU Lesser General Public License as published
 +   by the Free Software Foundation, either version 3 of the License, or
 +   (at your option) any later version.
 +
 +   Guile is distributed in the hope that it will be useful, but WITHOUT
 +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 +   License for more details.
 +
 +   You should have received a copy of the GNU Lesser General Public
 +   License along with Guile.  If not, see
 +   <https://www.gnu.org/licenses/>.  */
  
  
  



reply via email to

[Prev in Thread] Current Thread [Next in Thread]