Shall we add argument check in mknodat()

Xishi Qiu qiuxishi at huawei.com
Sat Sep 20 09:05:27 UTC 2014


Hi,

I find mknodat() in glibc will check the argument, like this,

  ...
  /* We must convert the value to dev_t type used by the kernel.  */
  unsigned long long int k_dev =  (*dev) & ((1ULL << 32) - 1);
  if (k_dev != *dev)
    {
      __set_errno (EINVAL);
      return -1;
    }
  ...

So shall we add argument check in uclibc's mknodat() too?

int mknodat(int fd, const char *path, mode_t mode, dev_t dev)
{
	unsigned long long int k_dev;

	/* We must convert the value to dev_t type used by the kernel.  */
	k_dev = (dev) & ((1ULL << 32) - 1);

	// just like this?
	if (k_dev != dev)
	  {
	    __set_errno (EINVAL);
	    return -1;
	  }

	return INLINE_SYSCALL(mknodat, 4, fd, path, mode, (unsigned int)k_dev);
}

Thanks,
Xishi Qiu



More information about the uClibc mailing list