Fixed Problems with SHA256/384/512

Jul 7, 2008
20
1
There seems to be a problem with the builtin functions for SHA256, SHA384 and SHA512 running against filenames with embedded spaces. While the MD5 and SHA1 functions seem to work fine, SHA256 and SHA512 always return -1 and SHA384 doesn't even seem to exist as a function regardless of input. I tested using an explicit first parameter (not "s") to make sure that it is being treated as a filename and I also tested using both quoted and unquoted filenames. I created the following simple .btm file named "test file.btm" to demonstrate the problem:

[d:\dev]cat "test sha.btm"

ver
echo Testing ^%@md5["test sha.btm"]
echo %@md5["test sha.btm"]
echo Testing ^%@sha1["test sha.btm"]
echo %@sha1["test sha.btm"]
echo Testing ^%@sha256["test sha.btm"]
echo %@sha256["test sha.btm"]
echo Testing ^%@sha512["test sha.btm"]
echo %@sha512["test sha.btm"]
echo Testing ^%@sha384["test sha.btm"]
echo %@sha384["test sha.btm"]
and running the file I get the following output:

TCC 19.00.30 x64 Windows 10 [Version 6.3.10586]
Testing %@md5["test sha.btm"]
5743589F6AD60686194EAED077CE64E6
Testing %@sha1["test sha.btm"]
AE5323A88E967B21256B53DF8CF8CA52EDFD5F7F
Testing %@sha256["test sha.btm"]
-1
Testing %@sha512["test sha.btm"]
-1
Testing %@sha384["test sha.btm"]
TCC: (Sys) D:\dev\test sha.btm [11] Incorrect function.
"%@sha384["test sha.btm"]"
 
Apr 18, 2014
301
9
It seems to be quoted filenames that the @SHA functions don't like:

Code:
TCC  19.00.30 x64   Windows 10 [Version 6.3.10586]
TCC Build 30   Windows 10 Build 10586 

d:\temp>type foobar.txt
foobar
barfoo
foo foo foo
bar bar bar

d:\temp>echo %@sha512[foobar.txt]
C6F88EFB41CE06A4C1B02CB351A001B4ADD9DA8F13A20000CD4DF51B3AAF7155072BDA443EA1D9BDA9087A471146E2B5F18B854BFF2BDF0E2B
1CC517670DCD5D

d:\temp>echo %@sha512["foobar.txt"]
-1

The same thing happens with @SHA256.

I get the same failure for @SHA384 though, quotes or no quotes:

Code:
d:\temp>echo %@sha384[foobar.txt]
TCC: (Sys) Incorrect function.
"%@sha384[foobar.txt]"
 
Apr 18, 2014
301
9
Rex - can I just check with you if this is intended behaviour?

If the filename supplied to @CRC32 or @MD5 doesn't exist then the function returns -1. If the file name supplied to any of the @SHA functions doesn't exist then the filename is returned:

Code:
TCC  19.01.31 x64   Windows 10 [Version 6.3.10586]
TCC Build 31   Windows 10 Build 10586

d:\>dir foobar.txt

Volume in drive D is unlabeled      Serial number is 6882:65c2
TCC: (Sys) The system cannot find the file specified.
"D:\foobar.txt"
                   0 bytes in 0 files and 0 dirs
   1,195,820,294,144 bytes free

d:\>echo %@crc32["foobar.txt"]
-1

d:\>echo %@md5[foobar.txt]
-1

d:\>echo %@sha1[foobar.txt]
foobar.txt

d:\>echo %@sha256[foobar.txt]
foobar.txt

d:\>echo %@sha384[foobar.txt]
foobar.txt

d:\>echo %@sha512[foobar.txt]
foobar.txt

The help file specifies that @CRC32 and @MD5 return -1 in these circumstances, but doesn't specify the return value of the @SHA functions. I guess you might say as it's undefined then I can't complain!

I'm not actually complaining though, just want to check if returning the filename is intended of if the @SHA functions should be returning -1 in these circumstances.
 

rconn

Administrator
Staff member
May 14, 2008
12,404
152
Rex - can I just check with you if this is intended behaviour?

If the filename supplied to @CRC32 or @MD5 doesn't exist then the function returns -1. If the file name supplied to any of the @SHA functions doesn't exist then the filename is returned:

It should be returning a -1 -- however, the failure is occurring before the SHA* functions are called. I will add a fix for that in the next build.
 
Similar threads
Thread starter Title Forum Replies Date
Charles S. Roaten Problems with TCSTART.BTM Support 1
vefatica Office problems better Support 0
Peter Murschall TCC V26.01.3x Debugging has problems with Alias /R Support 1
Peter Murschall CMDebug 26.01.37 has problems with Alias Support 21
C unzip problems Support 2
C TCC 26 BATCOMP BTM problems? Support 5
Alpengreis WAD [v26 Beta RC3]: MSGBOX color problems Support 4
Alpengreis QUERYBOX problems Support 5
R New Cloud Storage Tab in TCC options causing problems Support 0
Craig Fitzgerald Problems using tcstart.btm Support 3
M Problems with @REGBREAD on remote system Support 4
K_Meinhard Help problems Support 3
S Problems with dir command in the debugger Support 5
D How to? Path problems in TCC20 Support 1
G Version 20.11 installed on Windows 10 problems Support 9
M WAD Set statements in () causes problems Support 8
M Fixed Set "VAR=VAL" format causes problems Support 12
H Problems with PSUBST Support 3
Alpengreis The TCMD Display problems and font size ... Support 2
cgunhouse Problems With IFTP Support 3
Gamegod Fixed TCC identify Chinese problems Support 30
vefatica 21-22 Update problems Support 8
T Problems with the new help format Support 18
cgunhouse Event Plugin Problems With 19.10.43 Support 2
C @replace and @xreplace problems Support 5
Alpengreis Forum problems? Support 0
Alpengreis [TC 19.0 Beta 22/23] Install/Update-"Problems" Support 4
P Problems registering Support 5
R Parser problems after build 44 Support 5
LowdhamStation Serial port problems Support 7
vefatica Is jpsoft.com having ISP problems? Support 10
M Problems when being logged in Support 4
vefatica Both IFTP problems remain in build 50 Support 35
vefatica IFTP problems (broken pipe?) Support 24
Joe Caverly VIEW window in a TCC tab window problems Support 5
S Forum Implementation Problems Support 2
S Forum (XenForo) problems Support 3
S Problems to create new threads Support 6
S Fixed CLIPMONITOR problems Support 9
Roedy WAD Minor long-standing install problems Support 6
E Problems with Tabbed Toolbar Support 2
S Log and foldermonitor problems Support 3
vefatica Installation problems Support 1
J Problems for a neophyte Support 30
C Active FTP Problems Support 4
J Still problems understanding "foldermonitor" Support 9
J syntax problems multiple commands (command & command) Support 4
J 4NT problems after going to Windows 7 Support 5
vefatica Installer problems Support 23
cgunhouse Problems with ProcessMonitor Support 6

Similar threads