From 805aac230223f45acc7db218eb64589a4adb390e Mon Sep 17 00:00:00 2001 From: sagitario Date: Tue, 12 Jul 2011 07:24:50 +0000 Subject: fix crash with compressed symbols expanding to more than 4096 characters --- CHANGES | 5 +++++ VERSION | 2 +- src/main.cpp | 6 ++++-- src/symutil.cpp | 4 ++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 30bd4b8..37af7af 100644 --- a/CHANGES +++ b/CHANGES @@ -150,3 +150,8 @@ Version history * fixed decoding of compressed symbols * added command line switch -n to disable symbol demangling * fixed crash with more than 32767 types + +unreleased Version 0.22 + + * added command line switch -s to specify the replacement character for '.' in symbols + * fixed another crash where compressed symbols expand to more than 4096 characters diff --git a/VERSION b/VERSION index 76d9889..8ee1176 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -VERSION = 0.21 +VERSION = 0.22 diff --git a/src/main.cpp b/src/main.cpp index 9b6c247..18c1631 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -87,7 +87,7 @@ int main(int argc, char** argv) printf("License for redistribution is given by the Artistic License 2.0\n"); printf("see file LICENSE for further details\n"); printf("\n"); - printf("usage: %s [-Dversion|-C|-n] [new-exe-file] [pdb-file]\n", argv[0]); + printf("usage: %s [-Dversion|-C|-n|-sC] [new-exe-file] [pdb-file]\n", argv[0]); return -1; } @@ -106,8 +106,10 @@ int main(int argc, char** argv) Dversion = 0; else if (argv[0][1] == 'n') demangleSymbols = false; + else if (argv[0][1] == 's' && argv[0][2]) + dotReplacementChar = argv[0][2]; else - fatal("unknwon option: %s", argv[0]); + fatal("unknown option: %s", argv[0]); } if (!img.load(argv[1])) diff --git a/src/symutil.cpp b/src/symutil.cpp index faed579..61a4fa0 100644 --- a/src/symutil.cpp +++ b/src/symutil.cpp @@ -33,6 +33,8 @@ int dsym2c(const BYTE* p, int len, char* cname, int maxclen) zpos = ((ch >> 3) & 7) + 1; // + zlen; if (zpos > cpos) break; + if (cpos + zlen >= maxclen) + break; for (int z = 0; z < zlen; z++) cname[cpos + z] = cname[cpos - zpos + z]; cpos += zlen; @@ -49,6 +51,8 @@ int dsym2c(const BYTE* p, int len, char* cname, int maxclen) zpos = (ch3 & 0x7f) | ((ch & 7) << 7); if (zpos > cpos) break; + if (cpos + zlen >= maxclen) + break; for(int z = 0; z < zlen; z++) cname[cpos + z] = cname[cpos - zpos + z]; cpos += zlen; -- cgit v0.12