Open Bug 1259058 Opened 8 years ago Updated 2 years ago

Use s_mp_setz() to fill the top digits with zeroes after shifting in s_mp_rshd()

Categories

(NSS :: Libraries, defect, P3)

Tracking

(firefox48 affected)

Tracking Status
firefox48 --- affected

People

(Reporter: ttaubert, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: good-first-bug, Whiteboard: [nss-qm])

Attachments

(2 files)

After shifting an mp_int to the right by |p| digits, s_mp_rshd() reduces USED() by |p| and zeroes out the previously used digits like so:

> MP_USED(mp) -= p;
> while (p-- > 0)
>   *dst++ = 0;

I suggest we could rather use s_mp_setz() here:

> MP_USED(mp) -= p;
> s_mp_setz(MP_DIGITS(mp) + MP_USED(mp), p);
Keywords: good-first-bug
Priority: -- → P3
I would like to work on this. How should I get started?
If you're new to NSS, the first step would be to set up everything and build NSS (see https://github.com/nss-dev/nss/blob/master/readme.md for how to do that). If you have a patch then, you can either upload it here in the bug or on to phabricator https://phabricator.services.mozilla.com/ (which is the preferred method but a little more invovled to set up) and request review on it.
I'm new to NSS, I have set up everything. Can you tell which particular file do I need to look up for fixing this?
Created a pull request on github: https://github.com/nss-dev/nss/pull/20
@@ -2978,8 +2978,7 @@
 
     MP_USED(mp) -= p;
     /* Fill the top digits with zeroes */
-    while (p-- > 0)
-        *dst++ = 0;
+    s_mp_setz(MP_DIGITS(mp) + MP_USED(mp), p);
 
 } /* end s_mp_rshd() */
Assignee: nobody → guptaaditi1709
Target Milestone: --- → 3.36
Attachment #8938324 - Flags: review?(franziskuskiefer)
Comment on attachment 8938324 [details] [diff] [review]
Used s_mp_setz() to fill the top digits with zeroes after shifting in s_mp_rshd()

Review of attachment 8938324 [details] [diff] [review]:
-----------------------------------------------------------------

Sorry for the delay (holidays and such). To request review you can set the review flag on the uploaded patch.

The patch looks good, but the patch doesn't apply because it has the wrong path. Can you re-generate the patch so it applies? (either hg export or git format-patch -1 <sha>)
Or even better, we usually use phabricator for reviews in NSS. You can use your bugzilla account at https://phabricator.services.mozilla.com/ and use arcanist (https://secure.phabricator.com/book/phabricator/article/arcanist_quick_start/) to upload your patch.
Attachment #8938324 - Flags: review?(franziskuskiefer)
Flags: needinfo?(guptaaditi1709)
Attached patch mpi_patch.patchSplinter Review
Used s_mp_setz() to fill the top digits with zeroes after shifting in s_mp_rshd()
Flags: needinfo?(guptaaditi1709)
Attachment #8940410 - Flags: review+
Besides also created a pull reguest on GitHub: https://github.com/nss-dev/nss/pull/20 ,if this helps.
Comment on attachment 8940410 [details] [diff] [review]
mpi_patch.patch

Review of attachment 8940410 [details] [diff] [review]:
-----------------------------------------------------------------

> Besides also created a pull reguest on GitHub: https://github.com/nss-dev/nss/pull/20 ,if this helps.

Github is a readonly mirror of the official mercurial repository, so unfortunately not.

To request review you have to set the review flag to ? with a name.

This looks like the same patch, it won't apply :(
Attachment #8940410 - Flags: review+

Here is a good Ansible role for who want to start playing with NSS:
Tip for good-first-bug: https://galaxy.ansible.com/marcusburghardt/ansible_role_nss

This good-first-bug hasn't had any activity for 6 months, it is automatically unassigned.
For more information, please visit auto_nag documentation.

Assignee: guptaaditi1709 → nobody
Whiteboard: [nss-qm]
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: