cinecert / asdcplib

AS-DCP and AS-02 File Access Library
Other
70 stars 54 forks source link

asdcp-unwrap will write timed-text ancillary resources to "/[UUID]" when file-prefix has no path #111

Closed dcbullock closed 2 years ago

dcbullock commented 2 years ago

If <file-prefix> does not include a path portion, asdcp-unwrap will try to write timed-text ancillary resources with a path prefix of "/". On any system that protects that directory, an error will occur. On others, the ancillary resources are written in an unexpected directory.

without path portion

asdcp-unwrap -v ../tt_3d_subs_png_blue_r1_24fps_9c4f6e97-adce-404c-bef4-023306c09611.mxf blue.xml
         EditRate: 24/1
ContainerDuration: 8640000
          AssetID: ac8291bf-cec9-4176-8fd9-07239282281a
    NamespaceName: http://www.smpte-ra.org/schemas/428-7/2014/DCST
    ResourceCount: 4
    9f49bb7e-ea88-4659-a615-617be0065c6f: application/x-font-opentype
    01000001-7eac-4972-a32e-f6bb483db621: image/png
    01000002-451a-447a-b922-215b9ea3f73a: image/png
    01000003-a316-4058-a4d6-25e290743dd8: image/png
Error opening file /9f49bb7e-ea88-4659-a615-617be0065c6f: Permission denied
9f49bb7e-ea88-4659-a615-617be0065c6f | application/x-font-opentype | 895200
Program stopped on error.
File open failure.

with path portion

asdcp-unwrap -v ../tt_3d_subs_png_blue_r1_24fps_9c4f6e97-adce-404c-bef4-023306c09611.mxf ./blue.xml
         EditRate: 24/1
ContainerDuration: 8640000
          AssetID: ac8291bf-cec9-4176-8fd9-07239282281a
    NamespaceName: http://www.smpte-ra.org/schemas/428-7/2014/DCST
    ResourceCount: 4
    9f49bb7e-ea88-4659-a615-617be0065c6f: application/x-font-opentype
    01000001-7eac-4972-a32e-f6bb483db621: image/png
    01000002-451a-447a-b922-215b9ea3f73a: image/png
    01000003-a316-4058-a4d6-25e290743dd8: image/png
9f49bb7e-ea88-4659-a615-617be0065c6f | application/x-font-opentype | 895200
01000001-7eac-4972-a32e-f6bb483db621 | image/png | 13868
01000002-451a-447a-b922-215b9ea3f73a | image/png | 14090
01000003-a316-4058-a4d6-25e290743dd8 | image/png | 14125
dcbullock commented 2 years ago

issue

This issue is a result of Kumu::PathDirname followed by Kumu::PathJoin.

Options.file_root == "blue.xml" - no path separator character

std::string out_path = Kumu::PathDirname(Options.file_root);

out_path == ""

result = Writer.OpenWrite(Kumu::PathJoin(out_path, Kumu::UUID(ri->ResourceID).EncodeHex(buf, 64)).c_str());

Since out_path is "", PathJoin returns a string that begins with the path separator. This results in a filename with a single path element, "/" - the root directory.

solution

Those change are both fairly invasive API changes that might break UNIX, Mac, or Windows file handling in other areas.

So, just check for out_path == "" in asdcp-test and asdcp-unwrap and replace with "./" before the call to Kumu::PathJoin.

dcbullock commented 2 years ago

Fixed by JH in 38484de .