Skip to content

Commit 6f243a2

Browse files
authored
Merge pull request #1489 from Tinyblargon/#1487
fix: `mount.slot` not validated
2 parents cb55b52 + d054fd3 commit 6f243a2

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

proxmox/Internal/resource/guest/lxc/mounts/schema_mount.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,23 @@ func SchemaMount() *schema.Schema {
2727
Summary: schemaID + " cannot be empty",
2828
Severity: diag.Error}}
2929
}
30-
if len(v) > 2 {
31-
if v[0:2] != prefixSchemaID {
30+
if len(v) > len(prefixSchemaID) {
31+
if v[0:len(prefixSchemaID)] != prefixSchemaID {
3232
return diag.Diagnostics{{
3333
Summary: schemaID + " must start with '" + prefixSchemaID + "'",
3434
Severity: diag.Error}}
3535
}
36-
num, err := strconv.ParseUint(v[2:], 10, 64) // validate that the rest is a number
36+
num, err := strconv.ParseUint(v[len(prefixSchemaID):], 10, 64) // validate that the rest is a number
3737
if err != nil || num > maximumID {
3838
return diag.Diagnostics{{
3939
Summary: "invalid " + schemaID,
4040
Severity: diag.Error}}
4141
}
42+
return nil
4243
}
43-
return nil
44+
return diag.Diagnostics{{
45+
Summary: schemaID + " must start with '" + prefixSchemaID + "'",
46+
Severity: diag.Error}}
4447
}},
4548
schemaType: {
4649
Type: schema.TypeString,

0 commit comments

Comments
 (0)