diff options
author | Mark H Weaver <mhw@netris.org> | 2018-10-14 02:22:22 -0400 |
---|---|---|
committer | Mark H Weaver <mhw@netris.org> | 2018-10-14 02:27:23 -0400 |
commit | fe73fedab40cf716cc39139a61c078e2c9a2f37f (patch) | |
tree | 9cc44d2d859ba8c3c75d38ad37397d81034f1cec /libguile | |
parent | b44f505f1571fc9c42e58982f161a9cfc81fb7f4 (diff) |
Fix list validation of *list->bytevector procedures.
Fixes <https://bugs.gnu.org/32938>.
Reported by Josh Datko <jbd@cryptotronix.com>.
* libguile/validate.h (SCM_VALIDATE_LIST_COPYLEN)
(SCM_VALIDATE_NONEMPTYLIST_COPYLEN): Use '!=' instead of '>=' to
validate the result of 'scm_ilength' after it has been stored in
the user variable 'cvar'.
* test-suite/tests/bytevectors.test: Add tests. Use '#:use-module'
instead of ':use-module' in 'define-module' form.
Diffstat (limited to 'libguile')
-rw-r--r-- | libguile/validate.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libguile/validate.h b/libguile/validate.h index a1b1b553a..237865547 100644 --- a/libguile/validate.h +++ b/libguile/validate.h @@ -3,8 +3,8 @@ #ifndef SCM_VALIDATE_H #define SCM_VALIDATE_H -/* Copyright (C) 1999, 2000, 2001, 2002, 2004, 2006, 2007, 2009, - * 2011, 2012, 2013, 2014 Free Software Foundation, Inc. +/* Copyright (C) 1999-2002, 2004, 2006, 2007, 2009, 2011-2014, + * 2018 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 @@ -255,16 +255,20 @@ SCM_ASSERT (scm_ilength (lst) > 0, lst, pos, FUNC_NAME); \ } while (0) +/* Note: we use (cvar != -1) instead of (cvar >= 0) below + in case 'cvar' is of unsigned type. */ #define SCM_VALIDATE_LIST_COPYLEN(pos, lst, cvar) \ do { \ cvar = scm_ilength (lst); \ - SCM_ASSERT (cvar >= 0, lst, pos, FUNC_NAME); \ + SCM_ASSERT (cvar != -1, lst, pos, FUNC_NAME); \ } while (0) +/* Note: we use (cvar != -1 && cvar != 0) instead of + (cvar >= 1) below in case 'cvar' is of unsigned type. */ #define SCM_VALIDATE_NONEMPTYLIST_COPYLEN(pos, lst, cvar) \ do { \ cvar = scm_ilength (lst); \ - SCM_ASSERT (cvar >= 1, lst, pos, FUNC_NAME); \ + SCM_ASSERT (cvar != -1 && cvar != 0, lst, pos, FUNC_NAME); \ } while (0) #define SCM_VALIDATE_ALISTCELL(pos, alist) \ |