Namespaces
Variants
Views
Actions

Talk:c/string/byte/strncat

From cppreference.com

[edit] UB of strncat_s

Writing beyond the end of array dest is buffer overflow:

                                            count
                  ----------------------------------
           src:   |                         .      |
                  ---------------------------------- 
                  |                         | '\0'
                  |                         |  |
                  V                         V  V               destsz
        --------------------------..............................
dest:   |         | \0 |         |                             .
        --------------------------..............................

Reading beyond the end of array src is buffer overflow:

                                                count
                  ---------------................
           src:   |             |               .
                  ---------------................
                  |                             | '\0'
                  |                             |  |
                  V                             V  V           destsz
        --------------------------------------------------------
dest:   |         | \0 |                                       |
        --------------------------------------------------------

Is there another case of UB? Newatthis (talk) 04:14, 18 September 2015 (PDT)