]> granicus.if.org Git - psmisc/commitdiff
fuser,prtstat: use standard sscanf flag for alloc
authorCraig Small <csmall@enc.com.au>
Mon, 25 Apr 2016 06:57:35 +0000 (16:57 +1000)
committerCraig Small <csmall@enc.com.au>
Mon, 25 Apr 2016 06:57:35 +0000 (16:57 +1000)
Previously GNU libc supported the a option in scanf, e.g.
%as to allocate the buffer for the scanned string. The manual
recommends to use m instead as it follows the standard.

src/fuser.c
src/prtstat.c

index ce8f9dbf06a4fce477d245537c73bd296a26c890..33bc10fcf3a0e6f4b33e35b93775ff719eb8ceb0 100644 (file)
@@ -1565,7 +1565,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
        while (fgets(line, BUFSIZ, fp) != NULL) {
                char *path;
                char *scanned_path = NULL;
-               if (sscanf(line, "%*x: %*x %*x %*x %*x %*d %d %as",
+               if (sscanf(line, "%*x: %*x %*x %*x %*x %*d %d %ms",
                           &scanned_inode, &scanned_path) != 2) {
                        if (scanned_path)
                                free(scanned_path);
index fee5f61febf3d167f882d0617b46eabc20d3c1b4..2f8679983c6713f15ad85e76d671f0a4b7dbc986 100644 (file)
@@ -241,7 +241,7 @@ static void print_stat(const int pid, const opt_type options)
   bptr++;
   pr = malloc(sizeof(struct proc_info));
   sscanf(bptr,
-         "%a[^)]) "
+         "%m[^)]) "
          "%c "
          "%d %d %d %d %d %d"
          "%lu %lu %lu %lu " /*flts*/