Skip to content

Commit c37f485

Browse files
committed
Another patch for Issue #1659
1 parent eb98946 commit c37f485

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

lib/core/dump.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,21 @@ def dbTableValues(self, tableValues):
432432

433433
dumpDbPath = tempDir
434434

435-
_ = re.sub(r"[^\w]", "_", normalizeUnicode(unsafeSQLIdentificatorNaming(table)))
436-
if len(_) < len(table) or IS_WIN and table.upper() in WINDOWS_RESERVED_NAMES:
437-
_ = unicodeencode(re.sub(r"[^\w]", "_", unsafeSQLIdentificatorNaming(table)))
438-
dumpFileName = os.path.join(dumpDbPath, "%s-%s.%s" % (_, hashlib.md5(unicodeencode(table)).hexdigest()[:8], conf.dumpFormat.lower()))
439-
warnFile = True
440-
else:
441-
dumpFileName = os.path.join(dumpDbPath, "%s.%s" % (_, conf.dumpFormat.lower()))
435+
dumpFileName = os.path.join(dumpDbPath, "%s.%s" % (unsafeSQLIdentificatorNaming(table), conf.dumpFormat.lower()))
436+
if not os.path.isfile(dumpFileName):
437+
try:
438+
openFile(dumpFileName, "w+b").close()
439+
except SqlmapSystemException:
440+
raise
441+
except:
442+
warnFile = True
443+
444+
_ = re.sub(r"[^\w]", "_", normalizeUnicode(unsafeSQLIdentificatorNaming(table)))
445+
if len(_) < len(table) or IS_WIN and table.upper() in WINDOWS_RESERVED_NAMES:
446+
_ = unicodeencode(re.sub(r"[^\w]", "_", unsafeSQLIdentificatorNaming(table)))
447+
dumpFileName = os.path.join(dumpDbPath, "%s-%s.%s" % (_, hashlib.md5(unicodeencode(table)).hexdigest()[:8], conf.dumpFormat.lower()))
448+
else:
449+
dumpFileName = os.path.join(dumpDbPath, "%s.%s" % (_, conf.dumpFormat.lower()))
442450

443451
appendToFile = os.path.isfile(dumpFileName) and any((conf.limitStart, conf.limitStop))
444452
dumpFP = openFile(dumpFileName, "wb" if not appendToFile else "ab")

0 commit comments

Comments
 (0)