diff options
Diffstat (limited to 'ws2a/bugcomment.c')
| -rw-r--r-- | ws2a/bugcomment.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/ws2a/bugcomment.c b/ws2a/bugcomment.c index c15e6ab..bb789ad 100644 --- a/ws2a/bugcomment.c +++ b/ws2a/bugcomment.c @@ -65,7 +65,7 @@ unsigned long hash(unsigned char *str){ } char* useridhash(char* str){ - char* hash = malloc(sizeof(char)*20); + char* hash = calloc(sizeof(char)*20,sizeof(char)); int i = (int)str[0]; int len = strlen(str); int tloop = i*20; @@ -73,19 +73,25 @@ char* useridhash(char* str){ unsigned int strp = 0; i = 0; while(i < tloop){ + printf("i:%d hashp:%u strp:%u tloop:%d\n",i,hashp,strp,tloop); char tchar = str[strp%len]; hash[hashp%20] += str[strp%len]; + str[strp%len]+=1; hashp+=(int)tchar; strp+=(int)(hashp*hashp); i++; } i = 0; + printf("Before characterizeing the hash, it was: %s\n",hash); while(i < 20){ + //printf("Normalizeing %c(%u) as %c(%u)\n",hash[i],(unsigned int)hash[i],(hash[i] % 92) + 32,(hash[i] % 92) + 32); unsigned int hashnum = hash[i]; unsigned int modedhashnum = hashnum % 92; + //printf("hashnum was %u, after mod it is:%u\n",hashnum,modedhashnum); hash[i] = modedhashnum + 32; i++; } + printf("Resulting hash was:%s\n",hash); return hash; } @@ -97,7 +103,7 @@ int main(){ char name[15]; char userid[20]; char comment[2048]; - char captcha[25]; + char captcha[30]; char bugid[5]; char* iname = strtok(data,"&"); @@ -143,10 +149,12 @@ int main(){ printf("Captcha incorrect"); return; } - + fclose(captchafile); char command[100]; sprintf(command,"rm \"%s.txt\"",captchapath); system(command); + sprintf(command,"rm \"%s.png\"",inputhash); + system(command); //Add comment to bug file char filepath[100]; @@ -166,6 +174,7 @@ int main(){ //printf("<p>comment:%s<p>dcomment:%s",comment,dcomment); //printf("Everything ok, inserting comment!"); fprintf(bugfile,"\n%s\n%s\n%s\n",dname,duid,dcomment); + fclose(bugfile); free(dname); free(duid); free(dcomment); |
