Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:security\tomoyo\realpath.c Create Date:2022-07-28 19:45:54
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:moyo_encode2 - Encode binary string to ascii string.*@str: String in binary format.*@str_len: Size of @str in byte.* Returns pointer to @str in ascii format on success, NULL otherwise.* This function uses kzalloc(), so caller must kfree() if this function

Proto:char *tomoyo_encode2(const char *str, int str_len)

Type:char

Parameter:

TypeParameterName
const char *str
intstr_len
25  len = 0
26  p = str
30  If Not p Then Return NULL
32  When i < str_len cycle
33  c = p[i]
35  If c == '\\' Then len += 2
37  Else if c > ' ' && c < 127 Then len++
39  Else len += 4
42  len++
44  cp = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
45  If Not cp Then Return NULL
47  cp0 = cp
48  p = str
49  When i < str_len cycle
50  c = p[i]
52  If c == '\\' Then
53  cp++ = '\\'
54  cp++ = '\\'
55  Else if c > ' ' && c < 127 Then
56  cp++ = c
57  Else
58  cp++ = '\\'
59  cp++ = (c >> 6) + '0'
60  cp++ = ( c >> 3 & 7) + '0'
61  cp++ = (c & 7) + '0'
64  Return cp0
Caller
NameDescribe
tomoyo_encodemoyo_encode - Encode binary string to ascii string.*@str: String in binary format.* Returns pointer to @str in ascii format on success, NULL otherwise.* This function uses kzalloc(), so caller must kfree() if this function* didn't return NULL.