Cedar: Add ProtoOptionString() in PROTO_IMPL, to generate default option values

The WireGuard implementation will have two options that should not have a fixed default value, because they represent two keys (one is preshared, the other is private).

Instead of handling these two options differently in ProtoNewContainer(), this commit adds a new function to PROTO_IMPL: ProtoOptionString().

ProtoOptionString() takes the option's name as argument and returns a heap-allocated string that will be used as value. The function returns NULL when the option doesn't need a randomized value.
This commit is contained in:
Davide Beatrici committed 2021-03-01 02:49:59 +01:00
1 parent d8aa470192
commit decfcecc97
4 files changed
+4 -1

No files matched your search

+1 -1
View File
@@ -291,7 +291,7 @@ PROTO_CONTAINER *ProtoContainerNew(const PROTO_IMPL *impl)
option->Bool = impl_option->Bool;
break;
case PROTO_OPTION_STRING:
option->String = CopyStr(impl_option->String);
option->String = impl_option->String != NULL ? CopyStr(impl_option->String) : impl->OptionStringValue(option->Name);
break;
default:
Debug("ProtoContainerNew(): unhandled option type %u!\n", impl_option->Type);