Page MenuHomeFreeBSD

md5(1): fix -c flag to work with input on stdin
ClosedPublic

Authored by allanjude on Jun 19 2020, 5:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Mar 22, 10:58 PM
Unknown Object (File)
Fri, Mar 22, 10:58 PM
Unknown Object (File)
Fri, Mar 22, 10:58 PM
Unknown Object (File)
Fri, Mar 22, 10:58 PM
Unknown Object (File)
Sat, Mar 9, 7:05 AM
Unknown Object (File)
Wed, Mar 6, 3:39 AM
Unknown Object (File)
Jan 27 2024, 4:18 AM
Unknown Object (File)
Jan 19 2024, 11:12 PM
Subscribers

Details

Summary

Previously, the -p and -c flags were ignored when reading from stdin
Additionally, -s and -c can be used together now.

PR: 247295

Test Plan

$ cat file | sha256 -c f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2; echo $?
f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2
0
$ cat file | sha256 -c dead1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc2beef; echo $?
f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2 [ Failed ]
2
$ sha256 -s foobar -c foobar; echo $?
SHA256 (foobar) = c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2 [ Failed ]
2

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

allanjude created this revision.
sbin/md5/md5.c
526 ↗(On Diff #73341)

If I'm reading this right, this is actually passing the address of buf (stack-allocated) back to the caller. I suspect we really want buf to go away and just pass in NULL, then make sure to free() the buffer in the callers.

sbin/md5/md5.c
526 ↗(On Diff #73341)

Yeah, we should use the buf[] that already exists in the calling context atleast

I think I'm happy with this revision. :-)

This revision is now accepted and ready to land.Jun 19 2020, 6:35 PM
This revision was automatically updated to reflect the committed changes.