virsh fails to read files larger than BUFSIZ bytes

* src/util.c (fread_file_lim): Use VIR_REALLOC_N, not VIR_ALLOC_N.
Bug introduced in 895d0fdf5b.
* tests/Makefile.am (test_scripts): Add read-bufsiz.
* tests/read-bufsiz: New test for the above.
This commit is contained in:
Jim Meyering
2008-06-19 14:30:52 +00:00
parent 2dc11b36a1
commit e09fab39a8
4 changed files with 53 additions and 2 deletions

View File

@@ -47,6 +47,7 @@ noinst_PROGRAMS = xmlrpctest xml2sexprtest sexpr2xmltest virshtest conftest \
test_scripts = \
daemon-conf \
int-overflow \
read-bufsiz \
read-non-seekable \
vcpupin

43
tests/read-bufsiz Executable file
View File

@@ -0,0 +1,43 @@
#!/bin/sh
# ensure that reading a file larger than BUFSIZ works
# Copyright (C) 2008 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program 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 General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
virsh --version
fi
. $srcdir/test-lib.sh
fail=0
# Output a valid definition, to be used as input.
virsh -c test:///default dumpxml 1 > xml || fail=1
for i in before after; do
# The largest BUFSIZ I've seen is 128K. This is slightly larger.
printf %132000s ' ' > sp || fail=1
in=in-$i
# Append or prepend enough spaces to push the size over the limit:
( test $i = before && cat sp xml || cat xml sp ) > $in || fail=1
virsh --connect test:///default define $in > out || fail=1
printf "Domain test defined from $in\n\n" > exp || fail=1
compare out exp || fail=1
done
(exit $fail); exit $fail