mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 06:38:37 -05:00
Remove all the "assert(len>0)" which forbade zero-length writes across the
from_backend() interface, after having made all implementations safe against being called with len==0 and possibly-NULL/undefined "data". (This includes making misc.c:bufchain_add() more robust in this area.) Assertion was originally added 2002-03-01; e.g., see plink.c:1.53 [r1571]. I believe this now shouldn't break anything. This should hopefully make `ppk-empty-comment' finally GO AWAY. (Tested with Unix PuTTY.) [originally from svn r3500] [r1571 == fdbd6978016e9fd87db7b3bfc33ff0da8bd3eea9]
This commit is contained in:
parent
5415873b3f
commit
8e2fd15bd5
2
misc.c
2
misc.c
@ -181,6 +181,8 @@ void bufchain_add(bufchain *ch, const void *data, int len)
|
|||||||
{
|
{
|
||||||
const char *buf = (const char *)data;
|
const char *buf = (const char *)data;
|
||||||
|
|
||||||
|
if (len == 0) return;
|
||||||
|
|
||||||
ch->buffersize += len;
|
ch->buffersize += len;
|
||||||
|
|
||||||
if (ch->tail && ch->tail->buflen < BUFFER_GRANULE) {
|
if (ch->tail && ch->tail->buflen < BUFFER_GRANULE) {
|
||||||
|
2
plink.c
2
plink.c
@ -180,8 +180,6 @@ int from_backend(void *frontend_handle, int is_stderr,
|
|||||||
{
|
{
|
||||||
int osize, esize;
|
int osize, esize;
|
||||||
|
|
||||||
assert(len > 0);
|
|
||||||
|
|
||||||
if (is_stderr) {
|
if (is_stderr) {
|
||||||
bufchain_add(&stderr_data, data, len);
|
bufchain_add(&stderr_data, data, len);
|
||||||
try_output(1);
|
try_output(1);
|
||||||
|
7
psftp.c
7
psftp.c
@ -1639,14 +1639,13 @@ int from_backend(void *frontend, int is_stderr, const char *data, int datalen)
|
|||||||
unsigned char *p = (unsigned char *) data;
|
unsigned char *p = (unsigned char *) data;
|
||||||
unsigned len = (unsigned) datalen;
|
unsigned len = (unsigned) datalen;
|
||||||
|
|
||||||
assert(len > 0);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* stderr data is just spouted to local stderr and otherwise
|
* stderr data is just spouted to local stderr and otherwise
|
||||||
* ignored.
|
* ignored.
|
||||||
*/
|
*/
|
||||||
if (is_stderr) {
|
if (is_stderr) {
|
||||||
fwrite(data, 1, len, stderr);
|
if (len > 0)
|
||||||
|
fwrite(data, 1, len, stderr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1656,7 +1655,7 @@ int from_backend(void *frontend, int is_stderr, const char *data, int datalen)
|
|||||||
if (!outptr)
|
if (!outptr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (outlen > 0) {
|
if ((outlen > 0) && (len > 0)) {
|
||||||
unsigned used = outlen;
|
unsigned used = outlen;
|
||||||
if (used > len)
|
if (used > len)
|
||||||
used = len;
|
used = len;
|
||||||
|
7
scp.c
7
scp.c
@ -178,14 +178,13 @@ int from_backend(void *frontend, int is_stderr, const char *data, int datalen)
|
|||||||
unsigned char *p = (unsigned char *) data;
|
unsigned char *p = (unsigned char *) data;
|
||||||
unsigned len = (unsigned) datalen;
|
unsigned len = (unsigned) datalen;
|
||||||
|
|
||||||
assert(len > 0);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* stderr data is just spouted to local stderr and otherwise
|
* stderr data is just spouted to local stderr and otherwise
|
||||||
* ignored.
|
* ignored.
|
||||||
*/
|
*/
|
||||||
if (is_stderr) {
|
if (is_stderr) {
|
||||||
fwrite(data, 1, len, stderr);
|
if (len > 0)
|
||||||
|
fwrite(data, 1, len, stderr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +194,7 @@ int from_backend(void *frontend, int is_stderr, const char *data, int datalen)
|
|||||||
if (!outptr)
|
if (!outptr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (outlen > 0) {
|
if ((outlen > 0) && (len > 0)) {
|
||||||
unsigned used = outlen;
|
unsigned used = outlen;
|
||||||
if (used > len)
|
if (used > len)
|
||||||
used = len;
|
used = len;
|
||||||
|
@ -4792,8 +4792,6 @@ int term_ldisc(Terminal *term, int option)
|
|||||||
|
|
||||||
int term_data(Terminal *term, int is_stderr, const char *data, int len)
|
int term_data(Terminal *term, int is_stderr, const char *data, int len)
|
||||||
{
|
{
|
||||||
assert(len > 0);
|
|
||||||
|
|
||||||
bufchain_add(&term->inbuf, data, len);
|
bufchain_add(&term->inbuf, data, len);
|
||||||
|
|
||||||
if (!term->in_term_out) {
|
if (!term->in_term_out) {
|
||||||
|
@ -170,8 +170,6 @@ int from_backend(void *frontend_handle, int is_stderr,
|
|||||||
{
|
{
|
||||||
int osize, esize;
|
int osize, esize;
|
||||||
|
|
||||||
assert(len > 0);
|
|
||||||
|
|
||||||
if (is_stderr) {
|
if (is_stderr) {
|
||||||
bufchain_add(&stderr_data, data, len);
|
bufchain_add(&stderr_data, data, len);
|
||||||
try_output(1);
|
try_output(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user