Compatibility shim for DecodePointer

This commit is contained in:
wuggy 2026-07-06 12:50:16 +01:00
commit bf743d6699

View file

@ -8,7 +8,22 @@
#include "secerr.h" #include "secerr.h"
#include "secasn1.h" /* for SEC_ASN1GetSubtemplate */ #include "secasn1.h" /* for SEC_ASN1GetSubtemplate */
#include "secitem.h"
/*
* Windows NT4 / 2000 / XP‑RTM do not provide EncodePointer / DecodePointer.
* On down‑level systems, the correct behaviour is to return the pointer unchanged.
*/
static __inline void* CompatDecodePointer(void* p)
{
return p;
}
static __inline void* CompatEncodePointer(void* p)
{
return p;
}
/* /*
* simple definite-length ASN.1 decoder * simple definite-length ASN.1 decoder
@ -402,7 +417,7 @@ DecodeInline(void* dest,
} }
static SECStatus static SECStatus
DecodePointer(void* dest, CompatDecodePointer(void* dest,
const SEC_ASN1Template* templateEntry, const SEC_ASN1Template* templateEntry,
SECItem* src, PLArenaPool* arena, PRBool checkTag) SECItem* src, PLArenaPool* arena, PRBool checkTag)
{ {
@ -428,7 +443,7 @@ DecodeImplicit(void* dest,
SECItem* src, PLArenaPool* arena) SECItem* src, PLArenaPool* arena)
{ {
if (templateEntry->kind & SEC_ASN1_POINTER) { if (templateEntry->kind & SEC_ASN1_POINTER) {
return DecodePointer((void*)((char*)dest), return CompatDecodePointer((void*)((char*)dest),
templateEntry, src, arena, PR_FALSE); templateEntry, src, arena, PR_FALSE);
} else { } else {
return DecodeInline((void*)((char*)dest), return DecodeInline((void*)((char*)dest),
@ -569,7 +584,7 @@ DecodeExplicit(void* dest,
if (SECSuccess == rv) { if (SECSuccess == rv) {
if (templateEntry->kind & SEC_ASN1_POINTER) { if (templateEntry->kind & SEC_ASN1_POINTER) {
rv = DecodePointer(dest, templateEntry, &subItem, arena, PR_TRUE); rv = CompatDecodePointer(dest, templateEntry, &subItem, arena, PR_TRUE);
} else { } else {
rv = DecodeInline(dest, templateEntry, &subItem, arena, PR_TRUE); rv = DecodeInline(dest, templateEntry, &subItem, arena, PR_TRUE);
} }
@ -696,7 +711,7 @@ DecodeItem(void* dest,
/* decode implicitly tagged components */ /* decode implicitly tagged components */
rv = DecodeImplicit(dest, templateEntry, &temp, arena); rv = DecodeImplicit(dest, templateEntry, &temp, arena);
} else if (kind & SEC_ASN1_POINTER) { } else if (kind & SEC_ASN1_POINTER) {
rv = DecodePointer(dest, templateEntry, &temp, arena, PR_TRUE); rv = CompatDecodePointer(dest, templateEntry, &temp, arena, PR_TRUE);
} else if (kind & SEC_ASN1_CHOICE) { } else if (kind & SEC_ASN1_CHOICE) {
rv = DecodeChoice(dest, templateEntry, &temp, arena); rv = DecodeChoice(dest, templateEntry, &temp, arena);
} else if (kind & SEC_ASN1_ANY) { } else if (kind & SEC_ASN1_ANY) {