File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Ignore the produced binary
2+ cshatag
3+
Original file line number Diff line number Diff line change @@ -74,7 +74,12 @@ char * fhash(FILE *f, char *hex)
7474 }
7575
7676 unsigned char * hash ;
77- hash = malloc (HASHLEN );
77+ hash = calloc (1 ,HASHLEN );
78+ if (NULL == hash )
79+ {
80+ fprintf (stderr , "Insufficient memory for hashing file" );
81+ exit (EXIT_FAILURE );
82+ }
7883 SHA256_Final (hash , & c );
7984
8085 //printf("%s\n",bin2hex(hash,HASHLEN));
@@ -184,7 +189,14 @@ char * formatxa(xa_t s)
184189 char * buf ;
185190 char * prettysha ;
186191 int buflen = HASHLEN * 2 + 100 ;
187- buf = malloc (buflen );
192+ buf = calloc (1 ,buflen );
193+
194+ if (NULL == buf )
195+ {
196+ fprintf (stderr , "Insufficient space to store hash stringed" );
197+ exit (EXIT_FAILURE );
198+ }
199+
188200 if (strlen (s .sha256 )> 0 )
189201 prettysha = s .sha256 ;
190202 else
You can’t perform that action at this time.
0 commit comments