[attribute] When updating attribution, zero out the anchor/sentinel prior to placing the new value in
This ensures that attribution codes that are shorter than the anchor/sentinel will not be mangled.
This commit is contained in:
Родитель
b7e8a81a53
Коммит
0950317f39
|
@ -274,6 +274,12 @@ int updateAttribution(AbstractFile* abstractIn, AbstractFile* abstractOut, const
|
|||
printf("anchorOffset: 0x%llx\n", anchorOffset);
|
||||
|
||||
ASSERT(rawAnchor + dataLen <= rawBuffer + attributionResource->rawLength, "data too long!");
|
||||
// Zero out the anchor area, in case the data is shorter than the anchor
|
||||
// Note that we're taking the strlen of `rawAnchor` and not the `anchor`
|
||||
// passed in. This ensures that the entire anchor is zero'ed, even if only
|
||||
// a prefix of it was provided.
|
||||
memset((void *)rawAnchor, 0, strlen(rawAnchor));
|
||||
// Copy the new data into the same spot the anchor was in
|
||||
memcpy((void *)rawAnchor, data, dataLen);
|
||||
|
||||
// Write the new block.
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
Make sure we have a fresh build:
|
||||
|
||||
$ export BUILDDIR=$TESTDIR/../build
|
||||
$ cd $BUILDDIR
|
||||
$ make 2> /dev/null >/dev/null
|
||||
$ cd $CRAMTMP
|
||||
|
||||
Prepare content and the attribution code:
|
||||
$ mkdir stagedir
|
||||
$ echo "content-a" >> stagedir/a
|
||||
$ sentinel="__MOZILLA__attribution-code"
|
||||
$ attribution_code="short"
|
||||
|
||||
Create the filesystem with the sentinel value in the attribute:
|
||||
|
||||
$ mkdir output
|
||||
$ cp $TESTDIR/empty.hfs output/short.hfs
|
||||
$ $BUILDDIR/hfs/hfsplus output/short.hfs add stagedir/a a
|
||||
$ $BUILDDIR/hfs/hfsplus output/short.hfs setattr a attr-key "$sentinel"
|
||||
|
||||
Build a DMG:
|
||||
|
||||
$ $BUILDDIR/dmg/dmg build output/short.hfs output/short.dmg "$sentinel" >/dev/null
|
||||
|
||||
Now attribute:
|
||||
|
||||
$ $BUILDDIR/dmg/dmg attribute output/short.dmg output/short-attributed.dmg "__MOZILLA__" "$attribution_code" >/dev/null
|
||||
|
||||
Extract the HFS from the attributed DMG, and check to see if the code is correct:
|
||||
|
||||
$ $BUILDDIR/dmg/dmg extract output/short-attributed.dmg output/short-attributed.hfs >/dev/null
|
||||
$ $BUILDDIR/hfs/hfsplus output/short-attributed.hfs getattr a attr-key | tr -d '\0'
|
||||
short (no-eol)
|
Загрузка…
Ссылка в новой задаче