|
|
@@ -33,7 +33,7 @@ MHD_asprintf (char **resultp, const char *format, ...)
|
|
|
size_t buf_size;
|
|
|
char *buf;
|
|
|
|
|
|
- buf_size = len + 1;
|
|
|
+ buf_size = (size_t) len + 1;
|
|
|
buf = (char *) malloc (buf_size * sizeof(char));
|
|
|
if (NULL != buf)
|
|
|
{
|
|
|
@@ -406,7 +406,7 @@ fill_v1_v2_form (const void *cls,
|
|
|
}
|
|
|
/* return static form */
|
|
|
response =
|
|
|
- MHD_create_response_from_buffer_with_free_callback (reply_len,
|
|
|
+ MHD_create_response_from_buffer_with_free_callback ((size_t) reply_len,
|
|
|
(void *) reply,
|
|
|
&free);
|
|
|
add_session_cookie (session, response);
|
|
|
@@ -749,16 +749,25 @@ main (int argc, char *const *argv)
|
|
|
fd_set es;
|
|
|
MHD_socket max;
|
|
|
uint64_t mhd_timeout;
|
|
|
+ unsigned int port;
|
|
|
|
|
|
if (argc != 2)
|
|
|
{
|
|
|
printf ("%s PORT\n", argv[0]);
|
|
|
return 1;
|
|
|
}
|
|
|
+ if ( (1 != sscanf (argv[1], "%u", &port)) ||
|
|
|
+ (0 == port) || (65535 < port) )
|
|
|
+ {
|
|
|
+ fprintf (stderr,
|
|
|
+ "Port must be a number between 1 and 65535.\n");
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
/* initialize PRNG */
|
|
|
srand ((unsigned int) time (NULL));
|
|
|
d = MHD_start_daemon (MHD_USE_ERROR_LOG,
|
|
|
- atoi (argv[1]),
|
|
|
+ (uint16_t) port,
|
|
|
NULL, NULL,
|
|
|
&create_response, NULL,
|
|
|
MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 15,
|
|
|
@@ -778,13 +787,17 @@ main (int argc, char *const *argv)
|
|
|
break; /* fatal internal error */
|
|
|
if (MHD_get_timeout64 (d, &mhd_timeout) == MHD_YES)
|
|
|
{
|
|
|
- tv.tv_sec = (time_t) mhd_timeout / 1000;
|
|
|
+#if ! defined(_WIN32) || defined(__CYGWIN__)
|
|
|
+ tv.tv_sec = (time_t) (mhd_timeout / 1000);
|
|
|
+#else /* Native W32 */
|
|
|
+ tv.tv_sec = (long) (mhd_timeout / 1000);
|
|
|
+#endif /* Native W32 */
|
|
|
tv.tv_usec = ((long) (mhd_timeout % 1000)) * 1000;
|
|
|
tvp = &tv;
|
|
|
}
|
|
|
else
|
|
|
tvp = NULL;
|
|
|
- if (-1 == select (max + 1, &rs, &ws, &es, tvp))
|
|
|
+ if (-1 == select ((int) max + 1, &rs, &ws, &es, tvp))
|
|
|
{
|
|
|
if (EINTR != errno)
|
|
|
fprintf (stderr,
|