Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 331889 - As sdm is given option --server=<number>, it always set id equal to 0 due to bug in code
Summary: As sdm is given option --server=<number>, it always set id equal to 0 due to ...
Status: RESOLVED FIXED
Alias: None
Product: PTP
Classification: Tools
Component: Debug SDM (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 5.0   Edit
Assignee: Greg Watson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-06 07:37 EST by Jan Koñczak CLA
Modified: 2010-12-07 14:17 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Koñczak CLA 2010-12-06 07:37:27 EST
Build Identifier: Option --server=<id> not parsed correctly

The --server option gets interpreted in file:
 src/impl/sdm_routing_table_file.c
in function:
 sdm_routing_table_init

Currently there is a check if the option starting chars match "--server" text.
Then everything after 8th char is parsed as long.
This means that eg. "=2" is parsed as long. Strtol fails, but the result gets unchecked and the default return value of 0 is taken as id.

Solution:
change to check for whole "--server=" option instead.


Patch:

===============================================================================
--- sdm_routing_table_file.c	2010-12-06 13:17:15.000000000 +0100
+++ sdm_routing_table_file_fix.c	2010-12-06 13:18:05.000000000 +0100
@@ -81,21 +81,21 @@
 	 *
 	 * Server sdm's can also have their ID's set using the "--server=id" option. This
 	 * allows the servers to be started by a non-MPI runtime.
 	 */
 
 	for (ch = 0; ch < argc; ch++) {
 		char * arg = argv[ch];
 		if (strncmp(arg, "--master", 8) == 0) {
 			break;
- 		} else if (strncmp(arg, "--server", 8) == 0) {
-			id = (int)strtol(arg+8, NULL, 10);
+ 		} else if (strncmp(arg, "--server=", 9) == 0) {
+			id = (int)strtol(arg+9, NULL, 10);
 		}
 	}
===============================================================================

Reproducible: Always
Comment 1 Greg Watson CLA 2010-12-07 14:17:05 EST
Fixed in head and 4.0