2
1

0003-COTP-fixed-possible-heap-buffer-overflow-when-handling-message.patch 989 B

123456789101112131415161718192021222324252627
  1. From 033ab5b6488250c8c3b838f25a7cbc3e099230bb Mon Sep 17 00:00:00 2001
  2. From: Michael Zillgith <michael.zillgith@mz-automation.de>
  3. Date: Wed, 12 Aug 2020 07:25:37 +0200
  4. Subject: [PATCH] - COTP: fixed possible heap buffer overflow when handling
  5. message with invalid (zero) value in length field (#250)
  6. [Retrieved from:
  7. https://github.com/mz-automation/libiec61850/commit/033ab5b6488250c8c3b838f25a7cbc3e099230bb]
  8. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  9. ---
  10. src/mms/iso_cotp/cotp.c | 3 +++
  11. 1 file changed, 3 insertions(+)
  12. diff --git a/src/mms/iso_cotp/cotp.c b/src/mms/iso_cotp/cotp.c
  13. index cbb34b36..8c37d262 100644
  14. --- a/src/mms/iso_cotp/cotp.c
  15. +++ b/src/mms/iso_cotp/cotp.c
  16. @@ -720,6 +720,9 @@ CotpConnection_readToTpktBuffer(CotpConnection* self)
  17. goto exit_waiting;
  18. }
  19. + if (self->packetSize <= bufPos)
  20. + goto exit_error;
  21. +
  22. readBytes = readFromSocket(self, buffer + bufPos, self->packetSize - bufPos);
  23. if (readBytes < 0)