diff --git a/src/value.cpp b/src/value.cpp index 2b412074..e02e465e 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -410,6 +410,7 @@ namespace Exiv2 { int AsciiValue::read(const std::string& buf) { value_ = buf; + // ensure count>0 and nul terminated # https://github.com/Exiv2/exiv2/issues/1484 if (value_.size() == 0 || value_[value_.size()-1] != '\0') value_ += '\0'; return 0; } diff --git a/tests/bugfixes/github/test_issue_1484.py b/tests/bugfixes/github/test_issue_1484.py new file mode 100644 index 00000000..d9a7e8e7 --- /dev/null +++ b/tests/bugfixes/github/test_issue_1484.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from system_tests import CaseMeta, CopyTmpFiles, path +@CopyTmpFiles("$data_path/Stonehenge.exv") + +class test_issue_1484(metaclass=CaseMeta): + url = "https://github.com/Exiv2/exiv2/issues/1484" + filename = path("$tmp_path/Stonehenge.exv") + commands = [ "$exiv2 -g Copyright $filename" + , "$exiv2 -M\"set Exif.Image.Copyright Ascii ''\" $filename" + , "$exiv2 -g Copyright $filename" + ] + stdout = ["","","""Exif.Image.Copyright Ascii 1 +"""] + stderr = [""]*len(commands) + retval = [ 1,0,0]