chiark / gitweb /
catalog: make sure strings are terminated
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 28 Mar 2013 03:16:32 +0000 (23:16 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 29 Mar 2013 03:45:59 +0000 (23:45 -0400)
commit18cd5fe99f70a55a2d6f2303d6ee0624942695b1
tree8eff0d48a233db8ee6876471dae9c54440059045
parentf45928521249bbaf5dbea84933ae2fcaf5354080
catalog: make sure strings are terminated

Coverity complains: systemd-199/src/journal/catalog.c:126:
buffer_size_warning: Calling strncpy with a maximum size argument of
32 bytes on destination array "i->language" of size 32 bytes might
leave the destination string unterminated.

...and unfortunately it was right. The string was defined as a
fixed-size string in some parts of the code, and used a
null-terminated string in others (e.g. in log statements). There's no
point in conserving one byte, so just define the max language tag
length to 31 bytes, and use null terminated strings everywhere.

Also, wrap some lines, zero-fill less bytes, use '\0' instead of just
0 to be more explicit that this is one byte.
src/journal/catalog.c