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)
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.


No differences found