Author: cem
Date: Wed Jan 29 04:33:45 2020
New Revision: 357243
URL: https://svnweb.freebsd.org/changeset/base/357243

Log:
  libpmc: jevents: Go ahead and use snprintf(3)
  
  Reported by:  Coverity
  CID:          1391362

Modified:
  head/lib/libpmc/pmu-events/jevents.c

Modified: head/lib/libpmc/pmu-events/jevents.c
==============================================================================
--- head/lib/libpmc/pmu-events/jevents.c        Wed Jan 29 04:32:06 2020        
(r357242)
+++ head/lib/libpmc/pmu-events/jevents.c        Wed Jan 29 04:33:45 2020        
(r357243)
@@ -921,7 +921,8 @@ is_leaf_dir(const char *fpath)
                        char path[PATH_MAX];
                        struct stat st;
 
-                       sprintf(path, "%s/%s", fpath, dir->d_name);
+                       snprintf(path, sizeof(path), "%s/%s", fpath,
+                           dir->d_name);
                        if (stat(path, &st))
                                break;
 
@@ -1080,10 +1081,6 @@ process_one_file(const char *fpath, const struct stat 
        return err;
 }
 
-#ifndef PATH_MAX
-#define PATH_MAX       4096
-#endif
-
 /*
  * Starting in directory 'start_dirname', find the "mapfile.csv" and
  * the set of JSON files for the architecture 'arch'.
@@ -1128,7 +1125,7 @@ main(int argc, char *argv[])
                return 2;
        }
 
-       sprintf(ldirname, "%s/%s", start_dirname, arch);
+       snprintf(ldirname, sizeof(ldirname), "%s/%s", start_dirname, arch);
 
        /* If architecture does not have any event lists, bail out */
        if (stat(ldirname, &stbuf) < 0) {
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to