diff options
author | Marius Halden <marius.h@lden.org> | 2019-02-26 02:06:19 +0100 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2019-02-26 02:06:19 +0100 |
commit | 51ffcda86f2417fe929fdaabad2903dfcad523f5 (patch) | |
tree | 1221ac180cdd68552a1f3a4c69697ea63eaf4954 /jail.go | |
parent | ca0043ccc98a575daade3197b22e321a7d3ad945 (diff) | |
download | gojail-51ffcda86f2417fe929fdaabad2903dfcad523f5.tar.gz gojail-51ffcda86f2417fe929fdaabad2903dfcad523f5.tar.bz2 gojail-51ffcda86f2417fe929fdaabad2903dfcad523f5.tar.xz |
Add test for get
Diffstat (limited to 'jail.go')
-rw-r--r-- | jail.go | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -36,6 +36,7 @@ package jail // } import "C" import "errors" +import "fmt" import "unsafe" const ( @@ -87,8 +88,6 @@ func mapToIov(params map[string]interface{}) (unsafe.Pointer, int, []unsafe.Poin i++ } - //C.print_iov((*C.struct_iovec)(iov), C.int(len(params)*2)) - return iov, len(params)*2, freeList } @@ -102,19 +101,19 @@ func iovToMap(iov unsafe.Pointer, niov int, params map[string]interface{}) { key = (*C.char)(C.get_iov_field((*C.struct_iovec)(iov), C.int(i+0), &key_len)) val = C.get_iov_field((*C.struct_iovec)(iov), C.int(i+1), &val_len) - go_key := C.GoStringN(key, C.int(key_len)) - if v, ok := params[go_key]; !ok { + go_key := C.GoString(key) + if v, ok := params[go_key]; ok { if _, ok := v.(int); ok { params[go_key] = int(*(*C.int)(val)) } else if _, ok := v.(string); ok { - params[go_key] = C.GoStringN((*C.char)(val), C.int(val_len)) + params[go_key] = C.GoString((*C.char)(val)) } else if _, ok := v.(bool); ok { // XXX: noop for now } else { panic("Got unknown type from kernel") } } else { - panic("Got unknown key from kernel") + panic(fmt.Sprintf("Got unknown key from kernel: %v", go_key)) } } } |