Skip to content

Commit e47227d

Browse files
committed
Validate ObjectPath before use in Conn.GetUnitProperties
Fixes issue #13.
1 parent c57eef5 commit e47227d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

dbus/methods.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package dbus
1818

1919
import (
20+
"errors"
2021
"github.com/guelfey/go.dbus"
2122
)
2223

@@ -145,6 +146,9 @@ func (c *Conn) GetUnitProperties(unit string) (map[string]interface{}, error) {
145146
var props map[string]dbus.Variant
146147

147148
path := ObjectPath("/org/freedesktop/systemd1/unit/" + unit)
149+
if !path.IsValid() {
150+
return nil, errors.New("invalid unit name: " + unit)
151+
}
148152

149153
obj := c.sysconn.Object("org.freedesktop.systemd1", path)
150154
err = obj.Call("org.freedesktop.DBus.Properties.GetAll", 0, "org.freedesktop.systemd1.Unit").Store(&props)

0 commit comments

Comments
 (0)