Closed Bug 1197313 Opened 9 years ago Closed 9 years ago

remove PR_snprintf calls in netwerk/

Categories

(Core :: Networking, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox45 --- fixed
b2g-v2.5 --- fixed

People

(Reporter: froydnj, Assigned: madhurimachatterjee03, Mentored)

References

(Blocks 1 open bug)

Details

(Whiteboard: [good first bug][lang=c++])

Attachments

(1 file, 5 obsolete files)

Steps: 1. Find all calls to PR_snprintf in netwerk/. 2. Add #include "mozilla/Snprintf.h" to the file(s). 3. Replace PR_snprintf(X, sizeof(X), ...) calls with snprintf_literal(X, ...). 4. Replace other PR_snprintf calls with snprintf. 5. Remove any #include "prprf.h" lines.
Attached patch 1197313.patch (obsolete) — Splinter Review
Attachment #8651449 - Flags: review?(nfroyd)
Hi Nathan, I attached a patch for this. Could you review it? I am sure it needs changes with format string characters, so let me know how to fix them. Assigning this issue to myself to not loose/forget it. Thanks
Assignee: nobody → gioyik
Comment on attachment 8651449 [details] [diff] [review] 1197313.patch Review of attachment 8651449 [details] [diff] [review]: ----------------------------------------------------------------- Thanks for the patch! A few minor format string fixes below, and a few mistranslated functions. ::: netwerk/cache/nsDiskCacheDeviceSQL.cpp @@ +175,5 @@ > file->AppendNative(nsPrintfCString("%X", dir1)); > file->AppendNative(nsPrintfCString("%X", dir2)); > > char leaf[64]; > + snprintf_literal(leaf, "%014llX-%X", hash, generation); The format string here should be "%014" PRIx64 "-%X". @@ +410,5 @@ > file->AppendNative(NS_LITERAL_CSTRING("placeholder")); > > for (generation = 0; ; ++generation) > { > + snprintf_literal(leaf, "%014llX-%X", hash, generation); Likewise here. @@ +424,5 @@ > } > } > else > { > + snprintf_literal(leaf, "%014llX-%X", hash, generation); Likewise here. ::: netwerk/protocol/http/Http2Session.cpp @@ +218,5 @@ > *line = 0; > LOG5(("%s", linebuf)); > } > line = linebuf; > + snprintf_literal(line, "%08X: ", index); The two snprintf_literal calls in this function should be snprintf calls. @@ +226,1 @@ > (reinterpret_cast<const uint8_t *>(data))[index]); Please fix up the indentation of this line. ::: netwerk/protocol/http/SpdySession31.cpp @@ +176,5 @@ > *line = 0; > LOG5(("%s", linebuf)); > } > line = linebuf; > + snprintf(line, "%08X: ", index); It looks like you have forgotten to specify a maximum # of characters to print here. @@ +184,1 @@ > ((unsigned char *)data)[index]); This should be an snprintf call, since |line| is not a character array. Please fix that, and please remember to fix the indentation too. ::: netwerk/protocol/http/nsHttpChannel.cpp @@ +841,5 @@ > } > > if (mResuming) { > char byteRange[32]; > + snprintf_literal(byteRange, "bytes=%llu-", mStartPos); The format string here should be "bytes=%" PRIu64 "-". @@ +2427,5 @@ > return NS_ERROR_FAILURE; > } > > char buf[64]; > + snprintf_literal(buf, "bytes=%lld-", partialLen); Likewise here, except it should be "bytes=%" PRId64 "-". ::: netwerk/protocol/http/nsHttpHandler.cpp @@ +1710,5 @@ > // Values below 10 require zero padding. > qval_str = "%s%s;q=0.%02u"; > } > > + wrote = snprintf_literal(p2, available, qval_str, comma, token, u); The two snprintf_literal calls here should be calls to snprintf instead. ::: netwerk/streamconv/converters/ParseFTPList.cpp @@ +490,1 @@ > "%lld", fsz); The format string here should be "%" PRId64.
Attachment #8651449 - Flags: review?(nfroyd) → feedback+
I would like to work on this bug, could I please get further information on this?
Assignee: gioyik → madhurimachatterjee03
Please review the patch and let me know whether anymore changes are required.
Attachment #8671396 - Flags: review?(nfroyd)
Comment on attachment 8671396 [details] [diff] [review] Made all the required changes according to the comment 3 Review of attachment 8671396 [details] [diff] [review]: ----------------------------------------------------------------- This looks good, just a few minor changes. Please fix those up, upload a new patch, and ask me for review again. Assuming everything looks good with that version, I'll take care of landing in for you. ::: netwerk/protocol/http/Http2Session.cpp @@ +218,5 @@ > *line = 0; > LOG5(("%s", linebuf)); > } > line = linebuf; > + snprintf(line, "%08X: ", index); It looks like you deleted the maximum length for snprintf here. @@ +223,3 @@ > line += 10; > } > + snprintf(line, "%02X ", (reinterpret_cast<const uint8_t *>(data))[index]); ...and here. ::: netwerk/protocol/http/SpdySession31.cpp @@ +181,3 @@ > line += 10; > } > + snprintf(line, "%02X ", ((unsigned char *)data)[index]); ...and here as well. ::: netwerk/protocol/http/nsHttpChannel.cpp @@ +2427,5 @@ > return NS_ERROR_FAILURE; > } > > char buf[64]; > + snprintf_literal(buf, "bytes=%" PRId+64 "-", partialLen); This should be PRId64 (no '+' character). ::: netwerk/protocol/http/nsHttpDigestAuth.cpp @@ +261,5 @@ > nsCOMPtr<nsISupportsPRUint32> v(do_QueryInterface(*sessionState)); > if (v) { > uint32_t nc; > v->GetData(&nc); > + snprintf(nonce_count, "%08x", ++nc); This should be snprintf_literal. ::: netwerk/streamconv/converters/ParseFTPList.cpp @@ -484,5 @@ > * So its rounded up to the next block, so what, its better > * than not showing the size at all. > */ > uint64_t fsz = uint64_t(strtoul(tokens[1], (char **)0, 10) * 512); > - PR_snprintf(result->fe_size, sizeof(result->fe_size), Did you do you diff from a clean copy of mozilla-central? This line is incomplete, so I'm not sure what code you based your patch off of.
Attachment #8671396 - Flags: review?(nfroyd) → feedback+
Please review this patch and let me know whether anymore changes are required.
Attachment #8671396 - Attachment is obsolete: true
Attachment #8671536 - Flags: review?(nfroyd)
Please review this patch and let me know whether anymore changes are required. Kindly excuse me for the previous comment.
Attachment #8671536 - Attachment is obsolete: true
Attachment #8671536 - Flags: review?(nfroyd)
Attachment #8671539 - Flags: review?(nfroyd)
Comment on attachment 8671539 [details] [diff] [review] Made all the required changes according to the comment 6 Review of attachment 8671539 [details] [diff] [review]: ----------------------------------------------------------------- Thanks for the fixups; just a couple more left. I'm not entirely sure if the global substitutions of mozilla/Snprintf.h in place of prprf.h are necessarily correct; the files could use other functions declared by prprf.h. But that's not something you need to worry about; I can take care of making sure the patch compiles everywhere, if you're not already verifying it compiles on your local machine. ::: netwerk/protocol/http/Http2Session.cpp @@ +239,3 @@ > line += 10; > } > + snprintf(line, 128, "%02X ", (reinterpret_cast<const uint8_t *>(data))[index]); This converted |128 - (line - linebuf)| into a bare 128. Please fix. ::: netwerk/protocol/http/SpdySession31.cpp @@ +190,3 @@ > line += 10; > } > + snprintf(line, 128, "%02X ", ((unsigned char *)data)[index]); Likewise here.
Attachment #8671539 - Flags: review?(nfroyd) → feedback+
Please review this patch and let me know whether anymore changes are required. Hope this one works.
Attachment #8671539 - Attachment is obsolete: true
Attachment #8671840 - Flags: review?(nfroyd)
Comment on attachment 8671840 [details] [diff] [review] Made all the required changes according to the comment 9 Review of attachment 8671840 [details] [diff] [review]: ----------------------------------------------------------------- Thanks for the patch, and for going through the revision process with me! I'll take care of getting it landed, though it might not land until early next week.
Attachment #8671840 - Flags: review?(nfroyd) → review+
Attachment #8651449 - Attachment is obsolete: true
Madhurima, your attachment 8671840 [details] [diff] [review] appears to not apply cleanly to mozilla-central. Could you please generate a patch that applies cleanly to (an unpatched) mozilla-central? Thanks!
Flags: needinfo?(madhurimachatterjee03)
Do let me know if this works.
Attachment #8671840 - Attachment is obsolete: true
Flags: needinfo?(madhurimachatterjee03)
Attachment #8680766 - Flags: review?(nfroyd)
Comment on attachment 8680766 [details] [diff] [review] Made the required changes according to comment 12 Review of attachment 8680766 [details] [diff] [review]: ----------------------------------------------------------------- Thanks for fixing things up. I'll take care of landing the patch!
Attachment #8680766 - Flags: review?(nfroyd) → review+
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
See Also: → 1221592
Depends on: 1295085
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: