// SPDX-License-Identifier: GPL-2.0-or-later /* Key to pathname encoder * * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com)
*/
/* * turn the raw key into something cooked * - the key may be up to NAME_MAX in length (including the length word) * - "base64" encode the strange keys, mapping 3 bytes of raw to four of * cooked * - need to cut the cooked key into 252 char lengths (189 raw bytes)
*/ bool cachefiles_cook_key(struct cachefiles_object *object)
{ const u8 *key = fscache_get_key(object->cookie), *kend; unsignedchar ch; unsignedint acc, i, n, nle, nbe, keylen = object->cookie->key_len; unsignedint b64len, len, print, pad; char *name, sep;
_enter(",%u,%*phN", keylen, keylen, key);
BUG_ON(keylen > NAME_MAX - 3);
print = 1; for (i = 0; i < keylen; i++) {
ch = key[i];
print &= cachefiles_filecharmap[ch];
}
/* If the path is usable ASCII, then we render it directly */ if (print) {
len = 1 + keylen;
name = kmalloc(len + 1, GFP_KERNEL); if (!name) returnfalse;
/* See if it makes sense to encode it as "hex,hex,hex" for each 32-bit * chunk. We rely on the key having been padded out to a whole number * of 32-bit words.
*/
n = round_up(keylen, 4);
nbe = nle = 0; for (i = 0; i < n; i += 4) {
u32 be = be32_to_cpu(*(__be32 *)(key + i));
u32 le = le32_to_cpu(*(__le32 *)(key + i));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.