target: fix pr_out length in iscsi_parse_pr_out_transport_id
authorJoern Engel <joern@logfs.org>
Tue, 2 Sep 2014 21:49:59 +0000 (17:49 -0400)
committerNicholas Bellinger <nab@linux-iscsi.org>
Wed, 17 Sep 2014 22:17:35 +0000 (15:17 -0700)
Old code in iscsi_parse_pr_out_transport_id() was obviously buggy
and effectively ignored the high byte.

Found by coverity.

Signed-off-by: Joern Engel <joern@logfs.org>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_fabric_lib.c

index 0d1cf8b4f49f64a182287f1c74e05a841fce6a30..35bfe77160d86828b6511034787862f74788addc 100644 (file)
@@ -394,9 +394,9 @@ char *iscsi_parse_pr_out_transport_id(
         * If the caller wants the TransportID Length, we set that value for the
         * entire iSCSI Tarnsport ID now.
         */
-        if (out_tid_len != NULL) {
-               add_len = ((buf[2] >> 8) & 0xff);
-               add_len |= (buf[3] & 0xff);
+       if (out_tid_len) {
+               /* The shift works thanks to integer promotion rules */
+               add_len = (buf[2] << 8) | buf[3];
 
                tid_len = strlen(&buf[4]);
                tid_len += 4; /* Add four bytes for iSCSI Transport ID header */