mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-01-12 19:20:28 +03:00
Fix userquota_compare() function
The AVL tree compare function requires that either -1, 0, or 1 be returned. However the strcmp() function only guarantees that a negative, zero, or positive value is returned. Therefore, the return value of strcmp() needs to be sanitized with AVL_ISIGN. This was initially overlooked because the x86_64 implementation of strcmp() happens to only returns the allowed values. This was observed on an aarch64 platform which behaves correctly but differently as described above. Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com> Reviewed-by: Richard Laager <rlaager@wiktel.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #5311 Closes #5313
This commit is contained in:
parent
9523b15ac1
commit
e4ffa98dca
@ -1355,12 +1355,15 @@ userquota_compare(const void *l, const void *r)
|
|||||||
{
|
{
|
||||||
const userquota_node_t *luqn = l;
|
const userquota_node_t *luqn = l;
|
||||||
const userquota_node_t *ruqn = r;
|
const userquota_node_t *ruqn = r;
|
||||||
|
int rv;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NB: can only access uqn_id because userquota_update_cache() doesn't
|
* NB: can only access uqn_id because userquota_update_cache() doesn't
|
||||||
* pass in an entire userquota_node_t.
|
* pass in an entire userquota_node_t.
|
||||||
*/
|
*/
|
||||||
return (strcmp(luqn->uqn_id, ruqn->uqn_id));
|
rv = strcmp(luqn->uqn_id, ruqn->uqn_id);
|
||||||
|
|
||||||
|
return (AVL_ISIGN(rv));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user