Prechádzať zdrojové kódy

Cast pointers with uintptr_t

Casting pointers to usigned int can result in truncations. uintptr_t is
the correct type to cast to when doing pointer arithmetic
Matt Clarkson 10 rokov pred
rodič
commit
bc7891f8da
1 zmenil súbory, kde vykonal 2 pridanie a 2 odobranie
  1. 2 2
      src/civetweb.c

+ 2 - 2
src/civetweb.c

@@ -4189,7 +4189,7 @@ static int parse_auth_header(struct mg_connection *conn,
 	if ((s == NULL) || (*s != 0)) {
 		return 0;
 	}
-	nonce ^= (unsigned long)(conn->ctx);
+	nonce ^= (uintptr_t)(conn->ctx);
 	if (nonce < conn->ctx->start_time) {
 		/* nonce is from a previous start of the server and no longer valid
 		 * (replay attack?) */
@@ -4420,7 +4420,7 @@ static void send_authorization_request(struct mg_connection *conn)
 		++conn->ctx->nonce_count;
 		(void)pthread_mutex_unlock(&conn->ctx->nonce_mutex);
 
-		nonce ^= (unsigned long)(conn->ctx);
+		nonce ^= (uintptr_t)(conn->ctx);
 		conn->status_code = 401;
 		conn->must_close = 1;