invalid error check in modbus_init_listen_tcp

Bug #274511 reported by kylesch
2
Affects Status Importance Assigned to Milestone
libmodbus
Fix Released
Low
Stéphane Raimbault

Bug Description

Hello,

I think that that the error checking on the return value of the accept() call in modbus_init_listen_tcp is checking the wrong variable. Here is a one-line patch that should fix the issue:

diff -Naur libmodbus-2.0.2.old/modbus/modbus.c libmodbus-2.0.2.new/modbus/modbus.c
--- libmodbus-2.0.2.old/modbus/modbus.c 2008-08-07 11:17:55.000000000 -0400
+++ libmodbus-2.0.2.new/modbus/modbus.c 2008-09-25 14:14:09.000000000 -0400
@@ -1827,7 +1827,7 @@

         addrlen = sizeof(struct sockaddr_in);
         mb_param->fd = accept(new_socket, (struct sockaddr *)&addr, &addrlen);
- if (ret < 0) {
+ if (mb_param->fd < 0) {
                 perror("accept");
                 close(new_socket);
                 new_socket = 0;

Related branches

Revision history for this message
Stéphane Raimbault (sra) wrote :

Thank you for your bug report kylesch.

Changed in libmodbus:
assignee: nobody → sra
importance: Undecided → Low
milestone: none → 2.0.3
status: New → Fix Committed
Changed in libmodbus:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.