@@ -1517,6 +1517,17 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
*nbytes = le16_to_cpu(pSMBr->CountHigh);
*nbytes = (*nbytes) << 16;
*nbytes += le16_to_cpu(pSMBr->Count);
+
+ /*
+ * Workaround: Some legacy servers (read OS/2) might incorrectly
+ * set CountHigh for normal writes resulting in wrong 'nbytes'
+ * value. So when the write returns successfully and the bytes
+ * written as returned by the server is greater than bytes
+ * requested, reset it to original bytes requested.
+ */
+
+ if (*nbytes > count)
+ *nbytes = count;
}
cifs_buf_release(pSMB);
@@ -1605,6 +1616,17 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
*nbytes = le16_to_cpu(pSMBr->CountHigh);
*nbytes = (*nbytes) << 16;
*nbytes += le16_to_cpu(pSMBr->Count);
+
+ /*
+ * Workaround: Some legacy servers (read OS/2) might incorrectly
+ * set CountHigh for normal writes resulting in wrong 'nbytes'
+ * value. So when the write returns successfully and the bytes
+ * written as returned by the server is greater than bytes
+ * requested, reset it to original bytes requested.
+ */
+
+ if (*nbytes > count)
+ *nbytes = count;
}
/* cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */