Merge pull request #279 from david-y-lam/master

Fix invalid left-shift of pid_t type by casting to large enough type
libnfs-4.0.0-vitalif
Ronnie Sahlberg 2018-12-26 12:41:21 +10:00 committed by GitHub
commit d21b48256e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -81,7 +81,9 @@ struct rpc_context *rpc_init_context(void)
free(rpc);
return NULL;
}
rpc->xid = salt + (uint32_t)rpc_current_time() + (getpid() << 16);
// Add PID to rpc->xid for easier debugging, making sure to cast
// pid to 32-bit type to avoid invalid left-shifts.
rpc->xid = salt + rpc_current_time() + ((uint32_t)getpid() << 16);
salt += 0x01000000;
rpc->fd = -1;
rpc->tcp_syncnt = RPC_PARAM_UNDEFINED;