You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe there are couple issues with the secure example for 4-initialization attack.
The discriminatorfield in the User struct is a misleading field name. It is not used in the code as a discriminator, in the sense that type-cosplay calls for, ie, to uniquely differentiate accounts. Further, a bool cannot even be used as a proper discriminant. It seems like the field should be renamed to is_initialized, because that is what it seems like it is being used for, an initialization flag.
If the purpose of the discriminator field is indeed intended to be used as an "initialization flag", there should not be a boolean NOT operator on line 13. If user.discriminator is false, ie, uninitialized, then it should be initialized. However, the logic dictates that if it is false, then the code returns an error. If it is true (initialized), then it is reinitialized. This is the opposite of what we want I believe.
The text was updated successfully, but these errors were encountered:
I believe there are couple issues with the secure example for 4-initialization attack.
discriminator
field in theUser
struct is a misleading field name. It is not used in the code as a discriminator, in the sense that type-cosplay calls for, ie, to uniquely differentiate accounts. Further, abool
cannot even be used as a proper discriminant. It seems like the field should be renamed tois_initialized
, because that is what it seems like it is being used for, an initialization flag.discriminator
field is indeed intended to be used as an "initialization flag", there should not be a boolean NOT operator on line 13. Ifuser.discriminator
is false, ie, uninitialized, then it should be initialized. However, the logic dictates that if it is false, then the code returns an error. If it is true (initialized), then it is reinitialized. This is the opposite of what we want I believe.The text was updated successfully, but these errors were encountered: