Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maint(gpg2john.c): add missing prototypes #5603

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 84 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,75 @@ 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,
NULL,
Symmetrically_Encrypted_and_MDC_Packet,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functions removed from the old/first array are separated by 8 other pointers, but here they're separated by only 7 NULLs. A bug?

Separately (but maybe related), I notice that the old array initializer had 65 lines, whereas the tag mask is such that there should probably be only 64 - a bug? Harmless?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first commit (f4df772) of gpg2john had that non-multiple of 4. Jim added a second typedef in 2fee9ee for #477.

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 +1695,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).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the john-samples examples are calling this else part. Anyway, the call to the method is correct.

} 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 +1720,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.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem.

} else
skip(len);
}
Expand Down
Loading