|
|
|
@ -63,19 +63,19 @@ _rand(char **rs){ |
|
|
|
|
int rc; |
|
|
|
|
rc = gnutls_rnd(GNUTLS_RND_NONCE, rnd.data, rnd.size); |
|
|
|
|
if (rc != GNUTLS_E_SUCCESS) { |
|
|
|
|
printf("Error in gnutls_rnd()"); |
|
|
|
|
fprintf(stderr, "Error in gnutls_rnd()\n"); |
|
|
|
|
goto out; |
|
|
|
|
} |
|
|
|
|
gnutls_datum_t hex; |
|
|
|
|
rc = gnutls_hex_encode2(&rnd, &hex); |
|
|
|
|
if (rc != GNUTLS_E_SUCCESS) { |
|
|
|
|
printf("Error in gnutls_hex_encode2()"); |
|
|
|
|
fprintf(stderr, "Error in gnutls_hex_encode2()\n"); |
|
|
|
|
goto out; |
|
|
|
|
} |
|
|
|
|
*rs = malloc(hex.size); |
|
|
|
|
rc = sprintf(*rs, "%s", hex.data); |
|
|
|
|
if (rc < 0) { |
|
|
|
|
printf("Error in sprintf()"); |
|
|
|
|
fprintf(stderr, "Error in sprintf()\n"); |
|
|
|
|
goto out; |
|
|
|
|
} |
|
|
|
|
out: |
|
|
|
@ -105,13 +105,13 @@ main(){ |
|
|
|
|
cgi = cgiInit(); |
|
|
|
|
char *ip = getenv("REMOTE_ADDR"); |
|
|
|
|
if (ip == NULL) { |
|
|
|
|
fprintf(stderr, "%s\n", "Env REMOTE_ADDR is not set"); |
|
|
|
|
fprintf(stderr, "Env REMOTE_ADDR is not set\n"); |
|
|
|
|
http_code = HTTP_ERROR; |
|
|
|
|
goto fcgi_out; |
|
|
|
|
} |
|
|
|
|
rc = _verify_ip(ip); |
|
|
|
|
if (rc != 0) { |
|
|
|
|
fprintf(stderr, "%s\n", "Incorrect REMOTE_ADDR"); |
|
|
|
|
fprintf(stderr, "Incorrect REMOTE_ADDR\n"); |
|
|
|
|
http_code = HTTP_BAD_REQUEST; |
|
|
|
|
goto fcgi_out; |
|
|
|
|
} |
|
|
|
@ -131,13 +131,13 @@ main(){ |
|
|
|
|
int max_try = 10; |
|
|
|
|
for (int i = 1; i <= max_try; i++) { |
|
|
|
|
if (i == max_try) { |
|
|
|
|
fprintf(stderr, "%s\n", "Error in random file loop"); |
|
|
|
|
fprintf(stderr, "Error in random file loop\n"); |
|
|
|
|
http_code = HTTP_ERROR; |
|
|
|
|
goto fcgi_out; |
|
|
|
|
} |
|
|
|
|
rc = _rand(&hex); |
|
|
|
|
if (rc < 0) { |
|
|
|
|
fprintf(stderr, "Error in _rand()"); |
|
|
|
|
fprintf(stderr, "Error in _rand()\n"); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (access(hex, F_OK) != 0) { |
|
|
|
|