diff options
author | Nobuhiro Hayashi <nobuhiro.hayashi@gmail.com> | 2010-12-03 12:09:09 +0900 |
---|---|---|
committer | Nobuhiro Hayashi <nobuhiro.hayashi@gmail.com> | 2010-12-03 12:09:09 +0900 |
commit | 54f2f0a3e46e4369285be8c25912fd45413114c0 (patch) | |
tree | 15db8bd5746fe42f23f86946eb4ca239ea2292e3 /apt-pkg/contrib/strutl.cc | |
parent | 4279ef3b0a35327a03955461fff3cd6821463457 (diff) |
Permit base256 encoded value in the numeric field of tar header.
Diffstat (limited to 'apt-pkg/contrib/strutl.cc')
-rw-r--r-- | apt-pkg/contrib/strutl.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 987f4c3a4..daf87c87f 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -968,6 +968,24 @@ bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base) return true; } /*}}}*/ +// Base256ToNum - Convert a fixed length binary to a number /*{{{*/ +// --------------------------------------------------------------------- +/* This is used in decoding the 256bit encoded fixed length fields in + tar files */ +bool Base256ToNum(const char *Str,unsigned long &Res,unsigned Len) +{ + int i; + if ((Str[0] & 0x80) == 0) + return false; + else + { + Res = Str[0] & 0x7F; + for(i=1; i<Len; i++) + Res = (Res<<8) + Str[i]; + return true; + } +} + /*}}}*/ // HexDigit - Convert a hex character into an integer /*{{{*/ // --------------------------------------------------------------------- /* Helper for Hex2Num */ |