From: Fredrik Tolf Date: Sat, 22 Dec 2007 06:14:32 +0000 (+0100) Subject: Merge branch 'master' of git.dolda2000.com:/srv/git/r/doldaconnect X-Git-Tag: 1.1~31 X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=8bd2d2694e31dfa1a56a909998f2d921285aa9e2;hp=6421be5fc011a093e35f5a2d42a8078de6ffdc0e;p=doldaconnect.git Merge branch 'master' of git.dolda2000.com:/srv/git/r/doldaconnect --- diff --git a/daemon/transfer.c b/daemon/transfer.c index bebe011..e2fe54e 100644 --- a/daemon/transfer.c +++ b/daemon/transfer.c @@ -292,8 +292,12 @@ void *transfergetdata(struct transfer *transfer, size_t *size) return(NULL); if((transfer->endpos >= 0) && (transfer->curpos + *size >= transfer->endpos)) { - *size = transfer->endpos - transfer->curpos; - buf = srealloc(buf, *size); + if((*size = transfer->endpos - transfer->curpos) == 0) { + free(buf); + buf = NULL; + } else { + buf = srealloc(buf, *size); + } } transfer->curpos += *size; bytesupload += *size; diff --git a/lib/guile/dolcon-guile.c b/lib/guile/dolcon-guile.c index 2b3de3b..e3e6db8 100644 --- a/lib/guile/dolcon-guile.c +++ b/lib/guile/dolcon-guile.c @@ -262,7 +262,17 @@ static SCM scm_dc_qcmd(SCM argv, SCM callback) dc_freewcsarr(toks); if(cmd != NULL) free(cmd); - return(scm_from_int(tag)); + if(tag == -1) { + if(errno == ENOSYS) { + scm_error(scm_str2symbol("no-such-cmd"), "dc-qcmd", "Invalid command name", SCM_EOL, SCM_BOOL_F); + } else if(errno == EINVAL) { + scm_error(scm_str2symbol("illegal-escape"), "dc-qcmd", "Invalid escape sequence", SCM_EOL, SCM_BOOL_F); + } else { + scm_syserror("dc-qcmd"); + } + } else { + return(scm_from_int(tag)); + } } static void login_scmcb(int err, wchar_t *reason, struct scmcb *scmcb) diff --git a/lib/uilib.c b/lib/uilib.c index b235105..26429f8 100644 --- a/lib/uilib.c +++ b/lib/uilib.c @@ -212,8 +212,10 @@ static struct qcmd *makeqcmd(wchar_t *name) if((cmd->name != NULL) && !wcscmp(cmd->name, name)) break; } - if(cmd == NULL) + if(cmd == NULL) { + errno = ENOSYS; /* Bleh */ return(NULL); + } } new = smalloc(sizeof(*new)); new->tag = tag++; @@ -497,6 +499,7 @@ int dc_queuecmd(int (*callback)(struct dc_response *), void *data, ...) } else { if(buf != NULL) free(buf); + errno = EINVAL; return(-1); } } else {