Skip to content

Commit

Permalink
Fix for Issue #88 - ZMS crashing
Browse files Browse the repository at this point in the history
Previously, systems without gnutls were computing auth_md5 to be twice the size of what it was defined to be, thus causing zms to crash. The for loop at line 227 builds auth_md5 by looping every "2j", which means the upper limit (md5len) should be half the desired size of auth_md5.
  • Loading branch information
Andy committed Aug 28, 2013
1 parent a33ddcb commit 4e9698a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/zm_user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ User *zmLoadAuthUser( const char *auth, bool use_remote_addr )

char auth_key[512] = "";
char auth_md5[32+1] = "";
size_t md5len = 32;
size_t md5len = 16;
unsigned char md5sum[md5len];

time_t now = time( 0 );
Expand Down

4 comments on commit 4e9698a

@kylejohnson
Copy link
Member

Choose a reason for hiding this comment

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

This seems to have fixed the issue, but uh, why does it fix the issue?

@knight-of-ni
Copy link
Member

Choose a reason for hiding this comment

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

Notice that auth_md5 is defined to have 32+1 elements. Now scroll down to the "for" loop at line 227. Notice that it builds auth_md5 two characters (2*j) at a time. That means we need to loop half as many times as the size of auth_md5. If we loop 32 times, instead of 16, we build an auth_md5 with 64+1 elements, which exceeds what we defined earlier and causes the fault.

@kylejohnson
Copy link
Member

Choose a reason for hiding this comment

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

Thanks - you rock! Getting close to a stable release eh?

@knight-of-ni
Copy link
Member

Choose a reason for hiding this comment

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

I'm glad you took the time to organize this on github. I don't know how often you check the forum, but a couple people have posted their thanks for breathing new life into zoneminder. We are definitely making progress, but I'm not sure if this has been tested on Gentoo yet. Also, bleeding edge distros like Fedora might have unique compilation issues with their newer kernel and/or this thing called systemd, which I don't yet know anything about. I know a couple have tried to compile this on Fedora, but I have not seen any reports of success yet. May have to try it myself.

Please sign in to comment.