OpenSolaris

Printable Version Enter a New Search
Bug ID 6496621
Synopsis Simplify doprnt.c code with strnlen
State 7-Fix in Progress (Fix is in progress)
Category:Subcategory library:libc
Keywords oss-bite-size | oss-request | oss-sponsor | request-sponsor
Sponsor Jayakara Kini
Submitter ajishrao
Responsible Engineer Jayakara Kini
Reported Against
Duplicate Of
Introduced In
Commit to Fix snv_129
Fixed In
Release Fixed
Related Bugs 6478299
Submit Date 22-November-2006
Last Update Date 11-November-2009
Description
During the code review for CR 6478299, it was pointed out that the integration of strnlen would simplify lib/libc/port/print/doprnt.c:

                                        /*
                                         * XPG4 behavior - count
                                         * precision as bytes.
                                         * We don't use strlen() because
                                         * the given char string may not
                                         * be null-terminated.
                                         */
                                        char *qp;

                                        qp = memchr(bp, '\0', prec);
                                        if (qp == NULL) {
                                                p = bp + prec;
                                        } else {
                                                p = qp;
                                        }

Could be rewritten as:

					p = bp + strnlen(bp, (size_t) prec);
Work Around
N/A
Comments
N/A