![Linus Torvalds](/assets/img/avatar_default.png)
Pull strscpy string copy function implementation from Chris Metcalf. Chris sent this during the merge window, but I waffled back and forth on the pull request, which is why it's going in only now. The new "strscpy()" function is definitely easier to use and more secure than either strncpy() or strlcpy(), both of which are horrible nasty interfaces that have serious and irredeemable problems. strncpy() has a useless return value, and doesn't NUL-terminate an overlong result. To make matters worse, it pads a short result with zeroes, which is a performance disaster if you have big buffers. strlcpy(), by contrast, is a mis-designed "fix" for strlcpy(), lacking the insane NUL padding, but having a differently broken return value which returns the original length of the source string. Which means that it will read characters past the count from the source buffer, and you have to trust the source to be properly terminated. It also makes error handling fragile, since the test for overflow is unnecessarily subtle. strscpy() avoids both these problems, guaranteeing the NUL termination (but not excessive padding) if the destination size wasn't zero, and making the overflow condition very obvious by returning -E2BIG. It also doesn't read past the size of the source, and can thus be used for untrusted source data too. So why did I waffle about this for so long? Every time we introduce a new-and-improved interface, people start doing these interminable series of trivial conversion patches. And every time that happens, somebody does some silly mistake, and the conversion patch to the improved interface actually makes things worse. Because the patch is mindnumbing and trivial, nobody has the attention span to look at it carefully, and it's usually done over large swatches of source code which means that not every conversion gets tested. So I'm pulling the strscpy() support because it *is* a better interface. But I will refuse to pull mindless conversion patches. Use this in places where it makes sense, but don't do trivial patches to fix things that aren't actually known to be broken. * 'strscpy' of git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile: tile: use global strscpy() rather than private copy string: provide strscpy() Make asm/word-at-a-time.h available on all architectures
53 lines
1.2 KiB
Makefile
53 lines
1.2 KiB
Makefile
generic-y += auxvec.h
|
|
generic-y += bitsperlong.h
|
|
generic-y += bugs.h
|
|
generic-y += clkdev.h
|
|
generic-y += cputime.h
|
|
generic-y += device.h
|
|
generic-y += div64.h
|
|
generic-y += emergency-restart.h
|
|
generic-y += errno.h
|
|
generic-y += fb.h
|
|
generic-y += fcntl.h
|
|
generic-y += ftrace.h
|
|
generic-y += hardirq.h
|
|
generic-y += hw_irq.h
|
|
generic-y += ioctl.h
|
|
generic-y += ioctls.h
|
|
generic-y += ipcbuf.h
|
|
generic-y += irq_regs.h
|
|
generic-y += irq_work.h
|
|
generic-y += kmap_types.h
|
|
generic-y += kvm_para.h
|
|
generic-y += local.h
|
|
generic-y += local64.h
|
|
generic-y += mcs_spinlock.h
|
|
generic-y += mm-arch-hooks.h
|
|
generic-y += mman.h
|
|
generic-y += msgbuf.h
|
|
generic-y += param.h
|
|
generic-y += parport.h
|
|
generic-y += pci.h
|
|
generic-y += percpu.h
|
|
generic-y += poll.h
|
|
generic-y += posix_types.h
|
|
generic-y += preempt.h
|
|
generic-y += resource.h
|
|
generic-y += sembuf.h
|
|
generic-y += shmbuf.h
|
|
generic-y += siginfo.h
|
|
generic-y += socket.h
|
|
generic-y += sockios.h
|
|
generic-y += stat.h
|
|
generic-y += statfs.h
|
|
generic-y += termbits.h
|
|
generic-y += termios.h
|
|
generic-y += topology.h
|
|
generic-y += trace_clock.h
|
|
generic-y += types.h
|
|
generic-y += ucontext.h
|
|
generic-y += user.h
|
|
generic-y += vga.h
|
|
generic-y += word-at-a-time.h
|
|
generic-y += xor.h
|