diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2017-02-10 15:04:06 +0100 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2017-02-10 15:04:06 +0100 |
commit | 148781210fbcb1b26d5df678a400fa5dd8549e42 (patch) | |
tree | 78d57b0b68c54d029e47fdc834aacb0bc3815715 /lib/mpls.h | |
parent | Merge pull request #192 from donaldsharp/snmp1 (diff) | |
download | frr-148781210fbcb1b26d5df678a400fa5dd8549e42.tar.xz frr-148781210fbcb1b26d5df678a400fa5dd8549e42.zip |
lib: fix remaining coverity issues
Reported-by: Coverity
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/mpls.h')
-rw-r--r-- | lib/mpls.h | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/lib/mpls.h b/lib/mpls.h index 1f77aaa53..b5c1a653b 100644 --- a/lib/mpls.h +++ b/lib/mpls.h @@ -123,59 +123,40 @@ mpls_lse_decode (mpls_lse_t lse, mpls_label_t *label, /* Printable string for labels (with consideration for reserved values). */ static inline char * -label2str (mpls_label_t label, char *buf, int len) +label2str (mpls_label_t label, char *buf, size_t len) { switch(label) { case MPLS_V4_EXP_NULL_LABEL: - strncpy(buf, "IPv4 Explicit Null", len); + strlcpy(buf, "IPv4 Explicit Null", len); return(buf); - break; case MPLS_RA_LABEL: - strncpy(buf, "Router Alert", len); + strlcpy(buf, "Router Alert", len); return(buf); - break; case MPLS_V6_EXP_NULL_LABEL: - strncpy(buf, "IPv6 Explict Null", len); + strlcpy(buf, "IPv6 Explict Null", len); return(buf); - break; case MPLS_IMP_NULL_LABEL: - strncpy(buf, "implicit-null", len); + strlcpy(buf, "implicit-null", len); return(buf); - break; case MPLS_ENTROPY_LABEL_INDICATOR: - strncpy(buf, "Entropy Label Indicator", len); + strlcpy(buf, "Entropy Label Indicator", len); return(buf); - break; case MPLS_GAL_LABEL: - strncpy(buf, "Generic Associated Channel", len); + strlcpy(buf, "Generic Associated Channel", len); return(buf); - break; case MPLS_OAM_ALERT_LABEL: - strncpy(buf, "OAM Alert", len); + strlcpy(buf, "OAM Alert", len); return(buf); - break; case MPLS_EXTENSION_LABEL: - strncpy(buf, "Extension", len); + strlcpy(buf, "Extension", len); return(buf); - break; - case 4: - case 5: - case 6: - case 8: - case 9: - case 10: - case 11: - case 12: - strncpy(buf, "Reserved", len); - return(buf); - break; default: - sprintf(buf, "%u", label); + if (label < 16) + snprintf(buf, len, "Reserved (%u)", label); + else + snprintf(buf, len, "%u", label); return(buf); } - - strncpy(buf, "Error", len); - return(buf); } /* constants used by ldpd */ |