Skip to content

Commit

Permalink
sha2: fix another instance of -Wsizeof-pointer-memaccess (#26)
Browse files Browse the repository at this point in the history
When reviewing #24,
@davidpolverari pointed out a mistake I made in one revision - oops.

While fixing that, I noticed:
```
sha2.c: In function ‘SHA384_End’:
sha2.c:1052:45: error: argument to ‘sizeof’ in ‘memset’ call is the same expression as the destination; did you mean to dereference it? [-Werror=sizeof-pointer-memaccess]
 1052 |                 MEMSET_BZERO(context, sizeof(context));
      |                                             ^
sha2.c:176:49: note: in definition of macro ‘MEMSET_BZERO’
  176 | #define MEMSET_BZERO(p,l)       memset((p), 0, (l))
      |                                                 ^
cc1: some warnings being treated as errors
```

Let's fix that too, while we're at it.

Signed-off-by: Sam James <[email protected]>
  • Loading branch information
thesamesam authored May 2, 2024
1 parent 5f076fa commit e5e07cc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/sha2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ void SHA384_Final(SHA384_CTX* context, sha2_byte digest[]) {
}

/* Zero out state data */
MEMSET_BZERO(context, sizeof(context));
MEMSET_BZERO(context, sizeof(*context));
}

char *SHA384_End(SHA384_CTX* context, char buffer[]) {
Expand Down

0 comments on commit e5e07cc

Please sign in to comment.