Skip to content

Commit

Permalink
Fix handling of eof() in streambuffer underflow.
Browse files Browse the repository at this point in the history
@tomlankhorst has identified a serious bug which affected the
`ilostream` class.  If you opened a large object _as an ilostream,_
and it contained a byte with value `0xff` _at a buffer boundary,_
on a system where `char` is a signed type (such as x86-compatible
systems), then reading of the large object would **mistake the
`0xff` byte for end-of-file** and stop reading prematurely.
  • Loading branch information
tomlankhorst authored and jtv committed Feb 26, 2020
1 parent d15839e commit b20d2f1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
6.4.6
- `ilostream` could truncate at `0xff` byte at buffer boundary (#284, #286).
6.4.5
- Fixed "const" support in arguments to parameterised/prepared statements.
6.4.4
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.4.5
6.4.6
20 changes: 10 additions & 10 deletions configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for libpqxx 6.4.5.
# Generated by GNU Autoconf 2.69 for libpqxx 6.4.6.
#
# Report bugs to <Jeroen T. Vermeulen>.
#
Expand Down Expand Up @@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='libpqxx'
PACKAGE_TARNAME='libpqxx'
PACKAGE_VERSION='6.4.5'
PACKAGE_STRING='libpqxx 6.4.5'
PACKAGE_VERSION='6.4.6'
PACKAGE_STRING='libpqxx 6.4.6'
PACKAGE_BUGREPORT='Jeroen T. Vermeulen'
PACKAGE_URL=''

Expand Down Expand Up @@ -1365,7 +1365,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures libpqxx 6.4.5 to adapt to many kinds of systems.
\`configure' configures libpqxx 6.4.6 to adapt to many kinds of systems.

Usage: $0 [OPTION]... [VAR=VALUE]...

Expand Down Expand Up @@ -1436,7 +1436,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of libpqxx 6.4.5:";;
short | recursive ) echo "Configuration of libpqxx 6.4.6:";;
esac
cat <<\_ACEOF

Expand Down Expand Up @@ -1564,7 +1564,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
libpqxx configure 6.4.5
libpqxx configure 6.4.6
generated by GNU Autoconf 2.69

Copyright (C) 2012 Free Software Foundation, Inc.
Expand Down Expand Up @@ -2054,7 +2054,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by libpqxx $as_me 6.4.5, which was
It was created by libpqxx $as_me 6.4.6, which was
generated by GNU Autoconf 2.69. Invocation command line was

$ $0 $@
Expand Down Expand Up @@ -4162,7 +4162,7 @@ fi

# Define the identity of the package.
PACKAGE='libpqxx'
VERSION='6.4.5'
VERSION='6.4.6'


cat >>confdefs.h <<_ACEOF
Expand Down Expand Up @@ -18778,7 +18778,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by libpqxx $as_me 6.4.5, which was
This file was extended by libpqxx $as_me 6.4.6, which was
generated by GNU Autoconf 2.69. Invocation command line was

CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -18844,7 +18844,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
libpqxx config.status 6.4.5
libpqxx config.status 6.4.6
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

Expand Down
11 changes: 6 additions & 5 deletions include/pqxx/largeobject.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,12 @@ protected:
virtual int_type underflow() override
{
if (this->gptr() == nullptr) return EoF();
char *const eb = this->eback();
const int_type res(static_cast<int_type>(
AdjustEOF(m_obj.cread(this->eback(), m_bufsize))));
this->setg(eb, eb, eb + ((res==EoF()) ? 0 : res));
return ((res == 0) or (res == EoF())) ? EoF() : *eb;
auto *const eb{this->eback()};
auto const res = AdjustEOF(
m_obj.cread(this->eback(), static_cast<std::size_t>(m_bufsize)));
this->setg(
eb, eb, eb + (res == EoF() ? 0 : static_cast<std::size_t>(res)));
return (res == EoF() || res == 0) ? EoF() : traits_type::to_int_type(*eb);
}

private:
Expand Down
2 changes: 1 addition & 1 deletion include/pqxx/version.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "pqxx/compiler-internal-pre.hxx"

/// Full libpqxx version string.
#define PQXX_VERSION "6.4.5"
#define PQXX_VERSION "6.4.6"
/// Library ABI version.
#define PQXX_ABI "6.4"

Expand Down

0 comments on commit b20d2f1

Please sign in to comment.