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