mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 00:50:12 +01:00
nmtui: handle write() errors correctly in nmt_newt_edit_string
It might happen that write() returns -1, but the errno is not EINTR. In that case, the length would be incremented by 1, and the data pointer to the data being written would be moved back by 1 byte on every error. Make it so that the function exits with an error if it indicates an error. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1971 Fixes:3bda3fb60c('nmtui: initial import of nmtui') (cherry picked from commit13317bd536)
This commit is contained in:
parent
69bbc0f4e9
commit
f1888900bd
1 changed files with 12 additions and 3 deletions
|
|
@ -416,9 +416,18 @@ nmt_newt_edit_string(const char *data)
|
|||
|
||||
len = data ? strlen(data) : 0;
|
||||
while (len) {
|
||||
do
|
||||
nwrote = write(fd, data, len);
|
||||
while (nwrote == -1 && errno == EINTR);
|
||||
nwrote = write(fd, data, len);
|
||||
|
||||
if (nwrote == -1) {
|
||||
if (errno == EINTR) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nmt_newt_message_dialog(_("Could not write to temporary file: %s"),
|
||||
nm_strerror_native(errno));
|
||||
nm_close(fd);
|
||||
goto done;
|
||||
}
|
||||
|
||||
len -= nwrote;
|
||||
data += nwrote;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue