Sitelet https://github.com/iputils/iputils/pull/409
Skip to content

Fix the problem of potential memory leakage. - #409

Closed
ggvl wants to merge 1 commit into
iputils:masterfrom
ggvl:master
Closed

ggvl wants to merge 1 commit into
iputils:masterfrom
ggvl:master

Conversation

@ggvl

@ggvl ggvl commented May 31, 2022

Copy link
Copy Markdown
Contributor

If user use '-p' opt multi-times, the previous pointer generated by
strdup functiong will be discarded.

Signed-off-by: lvgenggeng lvgenggeng@uniontech.com

@ggvl

ggvl commented May 31, 2022

Copy link
Copy Markdown
Contributor Author

@hwoarang need a maintainer to approve running workflows

@ggvl

ggvl commented Jun 1, 2022

Copy link
Copy Markdown
Contributor Author

@zx2c4 @rossburton @sfionov review please, thanks.

@ggvl

ggvl commented Jun 2, 2022

Copy link
Copy Markdown
Contributor Author

@zx2c4 @rossburton @hwoarang @sfionov need review, thanks.

@ggvl

ggvl commented Jun 6, 2022

Copy link
Copy Markdown
Contributor Author

@zx2c4 @rossburton @hwoarang @sfionov need review, thanks.

@rossburton

Copy link
Copy Markdown
Contributor

I'm not a maintainer, so I can't approve workflows.

However, that patch changes behaviour: if I pass -p twice then the second value is ignored. Conventionally, the second value will replace the first.

@ggvl

ggvl commented Jun 7, 2022 •

Copy link
Copy Markdown
Contributor Author

I'm not a maintainer, so I can't approve workflows.

However, that patch changes behaviour: if I pass -p twice then the second value is ignored. Conventionally, the second value will replace the first.

Yes. you are right. I will fixed this problem.

@ggvl

ggvl commented Jun 9, 2022

Copy link
Copy Markdown
Contributor Author

@zx2c4 @hwoarang @sfionov

@pevik

pevik commented Jun 14, 2022

Copy link
Copy Markdown
Contributor

@ggvl FYI not approved workflow is not blocking this, lack of my time block it. iputils have practically no functional tests, thus I need to look carefully into the code (there have been many regressions in the past in ping).
BTW I wonder why you don't have allowed GitHub Actions in your fork: https://github.com/ggvl/iputils/actions

@pevik pevik added this to the next release milestone Jun 14, 2022
@pevik

pevik commented Jun 14, 2022 •

Copy link
Copy Markdown
Contributor

However, that patch changes behaviour: if I pass -p twice then the second value is ignored. Conventionally, the second value will replace the first.

@rossburton IMHO last value is always used (in master, and after this change). Or do I miss something?
FYI ping from Busybox behaves the same.

@rossburton

rossburton commented Jun 14, 2022 via email

Copy link
Copy Markdown
Contributor

@pevik

pevik commented Jun 14, 2022

Copy link
Copy Markdown
Contributor

@ggvl LGTM, but let me have second look later.

@pevik

pevik commented Jun 15, 2022

Copy link
Copy Markdown
Contributor

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Comment thread ping/ping.c Outdated
@ggvl

ggvl commented Jun 15, 2022

Copy link
Copy Markdown
Contributor Author

@pevik

@pevik

pevik commented Jun 15, 2022

Copy link
Copy Markdown
Contributor

@ggvl Thinking it twice Could we merge just fixing the leak first:

--- ping/ping.c
+++ ping/ping.c
@@ -449,6 +449,7 @@ main(int argc, char **argv)
                        break;
                case 'p':
                        rts.opt_pingfilled = 1;
+                       free(outpack_fill);
                        outpack_fill = strdup(optarg);
                        if (!outpack_fill)
                                error(2, errno, _("memory allocation failed"));
  1. check for max 16 bytes is a separate issue, which should be in a separate commit (you haven't even mention it in the commit message, but separate commit would be better).
  2. I'm not sure if strlen(outpack_fill) > 16 is a correct check. Because pattern is in hex, busybox implementation simply checks if number is in 0..255 range.

@ggvl

ggvl commented Jun 16, 2022 •

Copy link
Copy Markdown
Contributor Author

@pevik Ok. Thanks for you advice.

  1. check for max 16 bytes is a separate issue, which should be in a separate commit (you haven't even mention it in the commit message, but separate commit would be better).

Fine. I will separate it.

  1. I'm not sure if strlen(outpack_fill) > 16 is a correct check. Because pattern is in hex, busybox implementation simply checks if number is in 0..255 range.

I read the fill() function and find it use isxdigit to check each byte in the readbuf, so the maxlen should be 32.

If user use '-p' opt multi-times, the previous pointer generated by
strdup function will be discarded.

Signed-off-by: lvgenggeng <lvgenggeng@uniontech.com>
@ggvl

ggvl commented Jun 17, 2022

Copy link
Copy Markdown
Contributor Author

@pevik This on is ok and I will commit the second patch later.

@pevik

pevik commented Jun 17, 2022

Copy link
Copy Markdown
Contributor

I read the fill() function and find it use isxdigit to check each byte in the readbuf, so the maxlen should be 32.

Agree, but it'd be worth to check why busybox implementation allows only 0..255 decimal value.
#412

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants