mirror of
https://github.com/github/codeql.git
synced 2026-08-04 17:33:18 +02:00
22 lines
492 B
C#
22 lines
492 B
C#
using System;
|
|
using System.Runtime.Serialization;
|
|
|
|
[Serializable]
|
|
public class PersonBad : ISerializable
|
|
{
|
|
public int Age;
|
|
|
|
public PersonBad(int age)
|
|
{
|
|
if (age < 0)
|
|
throw new ArgumentException(nameof(age));
|
|
Age = age;
|
|
}
|
|
|
|
[OnDeserializing]
|
|
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
|
|
{
|
|
Age = info.GetInt32("age"); // $ Alert[cs/serialization-check-bypass] // BAD - write is unsafe
|
|
}
|
|
}
|