/* find header line */ while (1)
{
p = find_str(p, datend, sep, strlen(sep)); if (p == NULL) return PXE_PGP_CORRUPT_ARMOR; /* it must start at beginning of line */ if (p == data || *(p - 1) == '\n') break;
p += strlen(sep);
}
*start_p = p;
p += strlen(sep);
/* check if header text ok */ for (; p < datend && *p != '-'; p++)
{ /* various junk can be there, but definitely not line-feed */ if (*p >= ' ') continue; return PXE_PGP_CORRUPT_ARMOR;
} if (datend - p < 5 || memcmp(p, sep, 5) != 0) return PXE_PGP_CORRUPT_ARMOR;
p += 5;
/* check if at end of line */ if (p < datend)
{ if (*p != '\n' && *p != '\r') return PXE_PGP_CORRUPT_ARMOR; if (*p == '\r')
p++; if (p < datend && *p == '\n')
p++;
} return p - *start_p;
}
int
pgp_armor_decode(const uint8 *src, int len, StringInfo dst)
{ const uint8 *p = src; const uint8 *data_end = src + len; long crc; const uint8 *base64_start,
*armor_end; const uint8 *base64_end = NULL;
uint8 buf[4]; int hlen; int blen; int res = PXE_PGP_CORRUPT_ARMOR;
/* armor start */
hlen = find_header(src, data_end, &p, 0); if (hlen <= 0) goto out;
p += hlen;
/* armor end */
hlen = find_header(p, data_end, &armor_end, 1); if (hlen <= 0) goto out;
/* skip comments - find empty line */ while (p < armor_end && *p != '\n' && *p != '\r')
{
p = memchr(p, '\n', armor_end - p); if (!p) goto out;
/* step to start of next line */
p++;
}
base64_start = p;
/* find crc pos */ for (p = armor_end; p >= base64_start; p--) if (*p == '=')
{
base64_end = p - 1; break;
} if (base64_end == NULL) goto out;
/* *Splittheheaderlinesatnewlinesand":"separators,andcollect *pointerstothekeysandvaluesinthereturnarrays.
*/
n = 0;
line = buf; for (;;)
{ /* find end of line */
eol = strchr(line, '\n'); if (!eol) break;
nextline = eol + 1; /* if the line ends in CR + LF, strip the CR */ if (eol > line && *(eol - 1) == '\r')
eol--;
*eol = '\0';
/* find colon+space separating the key and value */
colon = strstr(line, ": "); if (!colon) return PXE_PGP_CORRUPT_ARMOR;
*colon = '\0';
/* shouldn't happen, we counted the number of lines beforehand */ if (n >= hdrlines)
elog(ERROR, "unexpected number of armor header lines");
(*keys)[n] = line;
(*values)[n] = colon + 2;
n++;
/* step to start of next line */
line = nextline;
}
if (n != hdrlines)
elog(ERROR, "unexpected number of armor header lines");
*nheaders = n; return0;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-08-08)
¤
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.