client/x11: Silence false positive warnings from covscan
authorOndrej Holy <oholy@redhat.com>
Tue, 21 Aug 2018 07:07:15 +0000 (09:07 +0200)
committerOndrej Holy <oholy@redhat.com>
Wed, 22 Aug 2018 11:35:43 +0000 (13:35 +0200)
Add code annotation to silence false positive warnings from covscan
due to omitting termination \0.

buffer_size: Calling strncpy with a source string whose length (13 chars) is greater than or equal to the size argument (13) will fail to null-terminate "&tmp[cs]".

client/X11/generate_argument_docbook.c

index d37bf29..b700539 100644 (file)
@@ -52,8 +52,10 @@ LPSTR tr_esc_str(LPCSTR arg, bool format)
                                }
 
                                if (format)
+                                       /* coverity[buffer_size] */
                                        strncpy(&tmp[cs], "<replaceable>", len);
                                else
+                                       /* coverity[buffer_size] */
                                        strncpy(&tmp[cs], "&lt;", len);
 
                                cs += len;
@@ -71,8 +73,10 @@ LPSTR tr_esc_str(LPCSTR arg, bool format)
                                }
 
                                if (format)
+                                       /* coverity[buffer_size] */
                                        strncpy(&tmp[cs], "</replaceable>", len);
                                else
+                                       /* coverity[buffer_size] */
                                        strncpy(&tmp[cs], "&lt;", len);
 
                                cs += len;