}
/* now we have to retrieve the name of the parent directory */
- if (get_name(parent_dir, dir_vp, component) != OK) {
+ if ((r = get_name(parent_dir, dir_vp, component)) != OK) {
unlock_vnode(parent_dir);
unlock_vmnt(parent_vmp);
unlock_vnode(dir_vp);
unlock_vmnt(dir_vmp);
put_vnode(parent_dir);
put_vnode(dir_vp);
- return(ENOENT);
+ return(r);
}
len += strlen(component) + 1;
/* add the leading slash */
len = strlen(orig_path);
if (strlen(orig_path) >= PATH_MAX) return(ENAMETOOLONG);
- memmove(orig_path+1, orig_path, len);
+ memmove(orig_path+1, orig_path, len + 1 /* include terminating nul */);
orig_path[0] = '/';
/* remove trailing slash if there is any */
UNLINK(TEST_SYM_A);
UNLINK(TEST_SYM_B);
+ /* Test bind with garbage in sockaddr_un */
+ memset(&addr, '?', sizeof(struct sockaddr_un));
+ addr.sun_family = AF_UNIX;
+ addr.sun_path[0] = 'f';
+ addr.sun_path[1] = 'o';
+ addr.sun_path[2] = 'o';
+ addr.sun_path[3] = '\0';
+ SOCKET(sd, PF_UNIX, SOCK_STREAM, 0);
+ rc = bind(sd, (struct sockaddr *) &addr, strlen(addr.sun_path) + 1);
+ if (rc == -1) {
+ test_fail("bind() should have worked");
+ }
+ CLOSE(sd);
+ UNLINK(TEST_SUN_PATH);
+
debug("leaving test_bind()");
}