Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return value of snprintf not checked in qdbg_parse_ctxt_to_buf #21

Closed
hmaarrfk opened this issue May 15, 2019 · 1 comment
Closed

return value of snprintf not checked in qdbg_parse_ctxt_to_buf #21

hmaarrfk opened this issue May 15, 2019 · 1 comment

Comments

@hmaarrfk
Copy link

len += snprintf(buf + len, buflen - len,
"\t%-47s %#-10x %u\n",
entries[i].name, v, v);
}
len += snprintf(buf + len, buflen - len, "\n");
return len;
}

Proposed patch

diff --git a/QDMA/linux-kernel/libqdma/qdma_debugfs_queue.c b/QDMA/linux-kernel/libqdma/qdma_debugfs_queue.c
index 62c59ed..b623731 100644
--- a/QDMA/linux-kernel/libqdma/qdma_debugfs_queue.c
+++ b/QDMA/linux-kernel/libqdma/qdma_debugfs_queue.c
@@ -629,9 +629,16 @@ int qdbg_parse_ctxt_to_buf(u32 *ctxt,
                len += snprintf(buf + len, buflen - len,
                                "\t%-47s %#-10x %u\n",
                                entries[i].name, v, v);
+               if (len >= buflen){
+                       // Not enough memory
+                       return buflen - len;
+               }
        }
        len += snprintf(buf + len, buflen - len, "\n");
-
+       if (len >= buflen){
+               // Not enough memory
+               return buflen - len;
+       }
        return len;
 }
hmaarrfk added a commit to ramonaoptics/dma_ip_drivers that referenced this issue May 15, 2019
@sujathabanoth-xlnx
Copy link
Collaborator

Issue addressed in latest driver release, hance closing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants