Skip to content
Browse files

Don't crash if the auth file is truncated

  • Loading branch information...
1 parent cce81e0 commit 5f57b1107d319c2c408ee5031dd7592b5f2f456a @mxcl mxcl committed Jul 15, 2009
Showing with 2 additions and 1 deletion.
  1. +2 −1 resolvers/audioscrobbler/persistence-simple.c
View
3 resolvers/audioscrobbler/persistence-simple.c
@@ -59,7 +59,8 @@ bool scrobsub_retrieve_credentials()
FILE* fp = fopen_session_file("r");
if(!fp) return false;
scrobsub_session_key = malloc(33);
- fread(scrobsub_session_key, sizeof(char), 32, fp);
+ size_t r = fread(scrobsub_session_key, sizeof(char), 32, fp);
+ if(r!=32) {scrobsub_session_key = 0; return false;}
fseek(fp, 0, SEEK_END);
long n = ftell(fp)-32; //determine length of username
fseek(fp, 32, SEEK_SET);

0 comments on commit 5f57b11

Please sign in to comment.
Something went wrong with that request. Please try again.