about summary refs log tree commit homepage
path: root/mahoro.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-02-27 01:10:33 +0000
committerEric Wong <normalperson@yhbt.net>2011-02-27 01:21:17 +0000
commit9c14d0c61ae5c9ed16604d03d70dc3c4765563d0 (patch)
treed3b6cf7b4cfb9342f39d1baca4880a106ced9be0 /mahoro.c
parentc661c9be8b6ea636d0504136a06f8d98a6af3195 (diff)
downloadmahoro-9c14d0c61ae5c9ed16604d03d70dc3c4765563d0.tar.gz
disallow '\0' in C strings
It's a bug in user code if we try to open files with '\0' in it.
Diffstat (limited to 'mahoro.c')
-rw-r--r--mahoro.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/mahoro.c b/mahoro.c
index 49e3e45..3fd1e61 100644
--- a/mahoro.c
+++ b/mahoro.c
@@ -46,7 +46,7 @@ mahoro_initialize(argc, argv, self)
         switch(rb_scan_args(argc, argv, "02", &vflags, &vpath)) {
                 case 2:
                         if(!NIL_P(vpath)) {
-                                path = StringValuePtr(vpath);
+                                path = StringValueCStr(vpath);
                         }
                         /* fallthrough */
                 case 1:
@@ -77,7 +77,7 @@ mahoro_file(self, path)
         const char *msg;
         magic_t cookie = ((struct MagicCookie *) DATA_PTR(self))->cookie;
 
-        if(!(msg = magic_file(cookie, StringValuePtr(path)))) {
+        if(!(msg = magic_file(cookie, StringValueCStr(path)))) {
                 rb_raise(eMahoroError, "failed lookup: %s", magic_error(cookie));
         }