in reply to Re^2: Seeking with 'x' in unpack and out of bounds reads
in thread Seeking with 'x' in unpack and out of bounds reads
You could use the pattern "x4 (NN X8 N x4 /a N)*". Instead of skipping the length to get it later, you would fetch it twice and use it once. And at least in that case, the pattern doesn't fail on a x (actually, since the x4 in the parentheses skips the bytes read by the second N, you know that there is something to skip.
Though actually, the fact that this fails is a good thing, because you know here that for some reason, after the last chunk, there are still some bytes (between 1 and 3) that lets x4 skip at least once, but not four times in a row. IE, your data is invalid. Try unpack "H*", pack "H*", <DATA>;. It looks like pack isn't very smart with the \n at the end of the string.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Seeking with 'x' in unpack and out of bounds reads
by vr (Curate) on Apr 27, 2018 at 15:36 UTC | |
by Eily (Monsignor) on Apr 27, 2018 at 15:56 UTC |