From: David van Moolenbroek Date: Tue, 7 Aug 2012 11:09:09 +0000 (+0200) Subject: IS: resolve Coverity warnings X-Git-Tag: v3.2.1~398 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=aa5531fc678a4596171a31871b617394d0c7fee6;p=minix.git IS: resolve Coverity warnings --- diff --git a/servers/is/dmp.c b/servers/is/dmp.c index a33b7d077..bbae0f81c 100644 --- a/servers/is/dmp.c +++ b/servers/is/dmp.c @@ -99,11 +99,11 @@ static char *key_name(int key) static char name[15]; if(key >= F1 && key <= F12) - sprintf(name, " F%d", key - F1 + 1); + snprintf(name, sizeof(name), " F%d", key - F1 + 1); else if(key >= SF1 && key <= SF12) - sprintf(name, "Shift+F%d", key - SF1 + 1); + snprintf(name, sizeof(name), "Shift+F%d", key - SF1 + 1); else - sprintf(name, "?"); + strlcpy(name, "?", sizeof(name)); return name; } diff --git a/servers/is/dmp_fs.c b/servers/is/dmp_fs.c index 4fe27d571..ee486c99d 100644 --- a/servers/is/dmp_fs.c +++ b/servers/is/dmp_fs.c @@ -62,7 +62,7 @@ void fproc_dmp() static char * dmap_flags(int flags) { static char fl[10]; - strcpy(fl, "-----"); + strlcpy(fl, "-----", sizeof(fl)); if(flags & DRV_FORCED) fl[0] = 'F'; return fl; } @@ -72,18 +72,15 @@ static char * dmap_flags(int flags) *===========================================================================*/ static char * dmap_style(int dev_style) { - static char str[16]; switch(dev_style) { - case STYLE_DEV: strcpy(str, "STYLE_DEV"); break; - case STYLE_DEVA: strcpy(str, "STYLE_DEVA"); break; - case STYLE_TTY: strcpy(str, "STYLE_TTY"); break; - case STYLE_CTTY: strcpy(str, "STYLE_CTTY"); break; - case STYLE_CLONE: strcpy(str, "STYLE_CLONE"); break; - case STYLE_CLONE_A: strcpy(str, "STYLE_CLONE_A"); break; - default: strcpy(str, "UNKNOWN"); break; + case STYLE_DEV: return "STYLE_DEV"; + case STYLE_DEVA: return "STYLE_DEVA"; + case STYLE_TTY: return "STYLE_TTY"; + case STYLE_CTTY: return "STYLE_CTTY"; + case STYLE_CLONE: return "STYLE_CLONE"; + case STYLE_CLONE_A: return "STYLE_CLONE_A"; + default: return "UNKNOWN"; } - - return str; } /*===========================================================================* diff --git a/servers/is/dmp_kernel.c b/servers/is/dmp_kernel.c index bf8234f1c..830bcb8cd 100644 --- a/servers/is/dmp_kernel.c +++ b/servers/is/dmp_kernel.c @@ -63,7 +63,7 @@ extern struct minix_kerninfo *_minix_kerninfo; void kmessages_dmp() { struct kmessages *kmess; /* get copy of kernel messages */ - char print_buf[_KMESS_BUF_SIZE+1]; /* this one is used to print */ + static char print_buf[_KMESS_BUF_SIZE+1]; /* this one is used to print */ int start; /* calculate start of messages */ int r; int size;