Skip to content

Commit

Permalink
Set null-terminator after strncpy
Browse files Browse the repository at this point in the history
Summary: When the length of `pkcs12.second.c_str()` is equal to `length`, strncpy won't write a null-terminator at the end of the destination string, making the destination unsafe to read and potentially cause an overflow.

Reviewed By: lblasa

Differential Revision: D46934320

fbshipit-source-id: 5e7acd49523b80105bcc47471facd9ff23b8a2b8
  • Loading branch information
OctavianGuzu authored and facebook-github-bot committed Jul 3, 2023
1 parent 54b7d8f commit 7175185
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions iOS/FlipperKit/FlipperWebSocket.mm
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
return std::string("");
}
strncpy(password, pkcs12.second.c_str(), length);
password[length - 1] = '\0';
return pkcs12.first;
};
}
Expand Down

0 comments on commit 7175185

Please sign in to comment.