jcmturner / gokrb5

Pure Go Kerberos library for clients and services
Apache License 2.0
717 stars 243 forks source link

[bug]: out of range #519

Open zyy4676 opened 1 year ago

zyy4676 commented 1 year ago

微信图片_20230516012036

// Parse the Keytab bytes of a principal into a Keytab entry's principal. func parsePrincipal(b []byte, p int, c CCache, e *binary.ByteOrder) (princ principal) { if c.Version != 1 { //Name Type is omitted in version 1 princ.PrincipalName.NameType = readInt32(b, p, e) } nc := int(readInt32(b, p, e)) if c.Version == 1 { //In version 1 the number of components includes the realm. Minus 1 to make consistent with version 2 nc-- } lenRealm := readInt32(b, p, e) princ.Realm = string(readBytes(b, p, int(lenRealm), e)) for i := 0; i < nc; i++ { l := readInt32(b, p, e) princ.PrincipalName.NameString = append(princ.PrincipalName.NameString, string(readBytes(b, p, int(l), e))) } return princ }

lenRealm > b.len ,so "readBytes(b, p, int(lenRealm), e)" will "bounds out of range"