the length of the reply string correctly (the SASL libraries now care
if you pass in the wrong length).
* Revert previous attempt at fix for SASL issue as it
is the wrong approach.
+ * Fix in correct manner, by making sm_rrecord() and thus
+ sm_hear() set the length of the reply string correctly
+ (the SASL libraries now care if you pass in the wrong
+ length).
+
2008-04-29 Peter Maydell <pmaydell@chiark.greenend.org.uk>
* Cope with sasl_decode64() returning SASL_CONTINUE, as
fgets (buffer, BUFSIZ, sm_rfp);
*len = strlen (buffer);
- if (ferror (sm_rfp) || feof (sm_rfp))
+ /* *len should be >0 except on EOF, but check for safety's sake */
+ if (ferror (sm_rfp) || feof (sm_rfp) || (*len == 0))
return sm_rerror ();
if (buffer[*len - 1] != '\n')
while (getc (sm_rfp) != '\n' && !ferror (sm_rfp) && !feof (sm_rfp))
continue;
else
- if (buffer[*len - 2] == '\r')
+ if ((*len > 1) && (buffer[*len - 2] == '\r'))
*len -= 1;
- buffer[*len - 1] = 0;
+ *len -= 1;
+ buffer[*len] = 0;
return OK;
}