[Bug build/23987] New: shell-container leaks file descriptors.
carlos at redhat dot com
sourceware-bugzilla@sourceware.org
Fri Dec 14 20:01:00 GMT 2018
https://sourceware.org/bugzilla/show_bug.cgi?id=23987
Bug ID: 23987
Summary: shell-container leaks file descriptors.
Product: glibc
Version: 2.30
Status: NEW
Severity: normal
Priority: P2
Component: build
Assignee: unassigned at sourceware dot org
Reporter: carlos at redhat dot com
CC: carlos at redhat dot com
Target Milestone: ---
The following issues were discovered by static analysis.
support/shell-container.c:
copy_func:
114 dfd = open (dname, O_WRONLY | O_TRUNC | O_CREAT, 0600);
115 if (dfd < 0)
116 {
117 fprintf (stderr, "cp: unable to open %s for writing: %s\n",
118 dname, strerror (errno));
119 return 1;
120 }
Leaks sfd opened on line 99.
copy_func:
122 if (support_copy_file_range (sfd, 0, dfd, 0, st.st_size, 0) !=
st.st_size)
123 {
124 fprintf (stderr, "cp: cannot copy file %s to %s: %s\n",
125 sname, dname, strerror (errno));
126 return 1;
127 }
Leaks sfd/dfd opened on line 99/114.
Multiple runs of copy_func could leak fds.
run_command_array:
174 if (strcmp (argv[i], "<") == 0 && argv[i + 1])
175 {
176 new_stdin = open (argv[i + 1], O_WRONLY|O_CREAT|O_TRUNC, 0777);
177 ++i;
178 continue;
179 }
180 if (strcmp (argv[i], ">") == 0 && argv[i + 1])
181 {
182 new_stdout = open (argv[i + 1], O_WRONLY|O_CREAT|O_TRUNC, 0777);
183 ++i;
184 continue;
185 }
186 if (strcmp (argv[i], ">>") == 0 && argv[i + 1])
187 {
188 new_stdout = open (argv[i + 1], O_WRONLY|O_CREAT|O_APPEND, 0777);
189 ++i;
190 continue;
191 }
192 if (strcmp (argv[i], "2>") == 0 && argv[i + 1])
193 {
194 new_stderr = open (argv[i + 1], O_WRONLY|O_CREAT|O_TRUNC, 0777);
195 ++i;
196 continue;
197 }
Leak new_stdin, new_stdout and new_stderr when overwritten by open() return.
Multiple runs of run_command_array could leak fds.
We should fix this to make sure we don't have fd leak issues in the larger
tests. Also it tides up the static analysis warnings.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Glibc-bugs
mailing list