Definition at line 1047 of file saslprep.c.
1048{
1051 int input_size;
1052 char *result;
1053 int result_size;
1054 int count;
1056 bool contains_RandALCat;
1057 unsigned char *p;
1059
1060
1062
1063
1064
1065
1066
1068 {
1071 goto oom;
1073 }
1074
1075
1076
1077
1078
1079
1081 if (input_size < 0)
1084 goto oom;
1085
1087 if (!input_chars)
1088 goto oom;
1089
1090 p = (
unsigned char *)
input;
1091 for (
i = 0;
i < input_size;
i++)
1092 {
1095 }
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107 count = 0;
1108 for (
i = 0;
i < input_size;
i++)
1109 {
1111
1113 input_chars[count++] = 0x0020;
1115 {
1116
1117 }
1118 else
1119 input_chars[count++] = code;
1120 }
1121 input_chars[count] = (
pg_wchar)
'\0';
1122 input_size = count;
1123
1124 if (input_size == 0)
1125 goto prohibited;
1126
1127
1128
1129
1130
1132 if (!output_chars)
1133 goto oom;
1134
1135
1136
1137
1138
1139 for (
i = 0;
i < input_size;
i++)
1140 {
1142
1144 goto prohibited;
1146 goto prohibited;
1147 }
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170 contains_RandALCat = false;
1171 for (
i = 0;
i < input_size;
i++)
1172 {
1174
1176 {
1177 contains_RandALCat = true;
1178 break;
1179 }
1180 }
1181
1182 if (contains_RandALCat)
1183 {
1185 pg_wchar last = input_chars[input_size - 1];
1186
1187 for (
i = 0;
i < input_size;
i++)
1188 {
1190
1192 goto prohibited;
1193 }
1194
1197 goto prohibited;
1198 }
1199
1200
1201
1202
1203 result_size = 0;
1204 for (wp = output_chars; *wp; wp++)
1205 {
1206 unsigned char buf[4];
1207
1210 }
1211
1212 result =
ALLOC(result_size + 1);
1213 if (!result)
1214 goto oom;
1215
1216
1217
1218
1219
1220 p = (unsigned char *) result;
1221 for (wp = output_chars; *wp; wp++)
1222 {
1225 }
1226 Assert((
char *) p == result + result_size);
1227 *p = '\0';
1228
1231
1234
1235prohibited:
1236 if (input_chars)
1238 if (output_chars)
1240
1242
1243oom:
1244 if (input_chars)
1246 if (output_chars)
1248
1250}
Assert(PointerIsAligned(start, uint64))
static pg_wchar utf8_to_unicode(const unsigned char *c)
static unsigned char * unicode_to_utf8(pg_wchar c, unsigned char *utf8string)
static const pg_wchar unassigned_codepoint_ranges[]
static const pg_wchar non_ascii_space_ranges[]
static const pg_wchar RandALCat_codepoint_ranges[]
#define IS_CODE_IN_TABLE(code, map)
static const pg_wchar LCat_codepoint_ranges[]
static const pg_wchar commonly_mapped_to_nothing_ranges[]
static const pg_wchar prohibited_output_ranges[]
static int pg_utf8_string_len(const char *source)
bool pg_is_ascii(const char *str)
pg_wchar * unicode_normalize(UnicodeNormalizationForm form, const pg_wchar *input)
References ALLOC, Assert(), buf, commonly_mapped_to_nothing_ranges, FREE, i, input, IS_CODE_IN_TABLE, LCat_codepoint_ranges, MaxAllocSize, non_ascii_space_ranges, output, pg_is_ascii(), pg_utf8_string_len(), pg_utf_mblen, prohibited_output_ranges, RandALCat_codepoint_ranges, SASLPREP_INVALID_UTF8, SASLPREP_OOM, SASLPREP_PROHIBITED, SASLPREP_SUCCESS, STRDUP, unassigned_codepoint_ranges, UNICODE_NFKC, unicode_normalize(), unicode_to_utf8(), and utf8_to_unicode().
Referenced by pg_be_scram_build_secret(), pg_fe_scram_build_secret(), scram_init(), and scram_verify_plain_password().