Skip to content

Commit

Permalink
maint(gpg2john.c): add missing prototypes
Browse files Browse the repository at this point in the history
The clang compiler was complaining with the error message: "Passing
arguments to a function without a prototype is deprecated in all
versions of C".

Fix: openwall#5268.

Signed-off-by: Claudio André <dev@claudioandre.slmail.me>
  • Loading branch information
claudioandre-br committed Dec 3, 2024
1 parent 364b1ca commit 6614733
Showing 1 changed file with 83 additions and 9 deletions.
92 changes: 83 additions & 9 deletions src/gpg2john.c
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ Private_Packet(int len)
*/


typedef void (*funcptr)();
typedef void (*funcptr)(int);

private int get_new_len(int);
private int is_partial(int);
Expand Down Expand Up @@ -1294,8 +1294,8 @@ TAG[] = {
};
#define TAG_NUM (sizeof(TAG) * sizeof(string))

private void
(*tag_func[])() = {
private funcptr
tag_func[] = {
Reserved,
Public_Key_Encrypted_Session_Key_Packet,
Signature_Packet,
Expand All @@ -1305,7 +1305,7 @@ private void
Public_Key_Packet,
Secret_Subkey_Packet,
Compressed_Data_Packet,
Symmetrically_Encrypted_Data_Packet,
NULL,
Marker_Packet,
Literal_Data_Packet,
Trust_Packet,
Expand All @@ -1314,7 +1314,7 @@ private void
NULL,
NULL,
User_Attribute_Packet,
Symmetrically_Encrypted_and_MDC_Packet,
NULL,
Modification_Detection_Code_Packet,
NULL,
NULL,
Expand Down Expand Up @@ -1363,6 +1363,74 @@ private void
Private_Packet,
};

private void
(*tag_func4[])(int, int, int, char *) = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
Symmetrically_Encrypted_Data_Packet,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
Symmetrically_Encrypted_and_MDC_Packet,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
};

char *pkt_type(int tag) {
switch(tag) {
case 0: return "Reserved";
Expand Down Expand Up @@ -1626,10 +1694,13 @@ parse_packet(char *hash)
}
// else printf("(%d bytes)\n", len);

if (tag < TAG_NUM && tag_func[tag] != NULL) {
if (tag < TAG_NUM && (tag_func[tag] != NULL || tag_func4[tag] != NULL)) {
if (gpg_dbg)
fprintf(stderr, "Packet type %d, len %d at offset %d (Processing) (pkt-type %s) (Partial %s)\n", tag, len, offset, pkt_type(tag), partial?"yes":"no");
(*tag_func[tag])(len, 1, partial, hash); // first packet (possibly only one if partial is false).
if (tag_func[tag] != NULL)
(*tag_func[tag])(len);
else
(*tag_func4[tag])(len, 1, partial, hash); // first packet (possibly only one if partial is false).
} else {
if (gpg_dbg)
fprintf(stderr, "Packet type %d, len %d at offset %d (Skipping) (Partial %s)\n", tag, len, offset, partial?"yes":"no");
Expand All @@ -1648,10 +1719,13 @@ parse_packet(char *hash)
if (gpg_dbg)
fprintf(stderr, "\t(%d bytes) partial end\n", len);
}
if (tag < TAG_NUM && tag_func[tag] != NULL) {
if (tag < TAG_NUM && (tag_func[tag] != NULL || tag_func4[tag] != NULL)) {
if (gpg_dbg)
fprintf(stderr, "Packet type %d, len %d at offset %d (Processing) (pkt-type %s) (Partial %s)\n", tag, len, offset, pkt_type(tag), partial?"yes":"no");
(*tag_func[tag])(len, 0, partial, hash); // subsquent packets.
if (tag_func[tag] != NULL)
(*tag_func[tag])(len);
else
(*tag_func4[tag])(len, 0, partial, hash); // subsquent packets.
} else
skip(len);
}
Expand Down

0 comments on commit 6614733

Please sign in to comment.