mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
Fix a collection of type / format string mismatches.
Ilya Shipitsin sent me a list of errors reported by a tool 'cppcheck', which I hadn't seen before, together with some fixes for things already taken off that list. This change picks out all the things from the remaining list that I could quickly identify as actual errors, which it turns out are all format-string goofs along the lines of using a %d with an unsigned int, or a %u with a signed int, or (in the cases in charset/utf8.c) an actual _size_ mismatch which could in principle have caused trouble on a big-endian target.
This commit is contained in:
parent
892d4a0188
commit
20e36ae4a2
@ -267,7 +267,7 @@ void utf8_read_test(int line, char *input, int inlen, ...)
|
|||||||
}
|
}
|
||||||
if (l != str[i]) {
|
if (l != str[i]) {
|
||||||
printf("%d: char %d came out as %08x, should be %08x\n",
|
printf("%d: char %d came out as %08x, should be %08x\n",
|
||||||
line, i, str[i], l);
|
line, i, str[i], (unsigned)l);
|
||||||
total_errs++;
|
total_errs++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -306,7 +306,7 @@ void utf8_write_test(int line, const long *input, int inlen, ...)
|
|||||||
}
|
}
|
||||||
if (l != str[i]) {
|
if (l != str[i]) {
|
||||||
printf("%d: char %d came out as %08x, should be %08x\n",
|
printf("%d: char %d came out as %08x, should be %08x\n",
|
||||||
line, i, str[i], l);
|
line, i, str[i], (unsigned)l);
|
||||||
total_errs++;
|
total_errs++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
import.c
3
import.c
@ -445,7 +445,7 @@ static struct openssh_pem_key *load_openssh_pem_key(const Filename *filename,
|
|||||||
if (!strcmp(p, "ENCRYPTED"))
|
if (!strcmp(p, "ENCRYPTED"))
|
||||||
ret->encrypted = TRUE;
|
ret->encrypted = TRUE;
|
||||||
} else if (!strcmp(line, "DEK-Info")) {
|
} else if (!strcmp(line, "DEK-Info")) {
|
||||||
int i, j, ivlen;
|
int i, ivlen;
|
||||||
|
|
||||||
if (!strncmp(p, "DES-EDE3-CBC,", 13)) {
|
if (!strncmp(p, "DES-EDE3-CBC,", 13)) {
|
||||||
ret->encryption = OP_E_3DES;
|
ret->encryption = OP_E_3DES;
|
||||||
@ -459,6 +459,7 @@ static struct openssh_pem_key *load_openssh_pem_key(const Filename *filename,
|
|||||||
}
|
}
|
||||||
p = strchr(p, ',') + 1;/* always non-NULL, by above checks */
|
p = strchr(p, ',') + 1;/* always non-NULL, by above checks */
|
||||||
for (i = 0; i < ivlen; i++) {
|
for (i = 0; i < ivlen; i++) {
|
||||||
|
unsigned j;
|
||||||
if (1 != sscanf(p, "%2x", &j)) {
|
if (1 != sscanf(p, "%2x", &j)) {
|
||||||
errmsg = "expected more iv data in DEK-Info";
|
errmsg = "expected more iv data in DEK-Info";
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -2014,7 +2014,7 @@ int main(int argc, char **argv)
|
|||||||
unsigned long chr = strtoul(argv[i], NULL, 0);
|
unsigned long chr = strtoul(argv[i], NULL, 0);
|
||||||
int type = getType(chr);
|
int type = getType(chr);
|
||||||
assert(typetoname[type].type == type);
|
assert(typetoname[type].type == type);
|
||||||
printf("U+%04x: %s\n", chr, typetoname[type].name);
|
printf("U+%04x: %s\n", (unsigned)chr, typetoname[type].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
3
misc.c
3
misc.c
@ -157,7 +157,8 @@ int main(void)
|
|||||||
passes++; \
|
passes++; \
|
||||||
} else { \
|
} else { \
|
||||||
printf("fail: %s(%s,%s)%s = %u, expected %u\n", \
|
printf("fail: %s(%s,%s)%s = %u, expected %u\n", \
|
||||||
#func, #string, #arg2, #suffix, ret, result); \
|
#func, #string, #arg2, #suffix, ret, \
|
||||||
|
(unsigned)result); \
|
||||||
fails++; \
|
fails++; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
2
pscp.c
2
pscp.c
@ -1476,7 +1476,7 @@ int scp_get_sink_action(struct scp_sink_action *act)
|
|||||||
act->action = SCP_SINK_ENDDIR;
|
act->action = SCP_SINK_ENDDIR;
|
||||||
return 0;
|
return 0;
|
||||||
case 'T':
|
case 'T':
|
||||||
if (sscanf(act->buf, "%ld %*d %ld %*d",
|
if (sscanf(act->buf, "%lu %*d %lu %*d",
|
||||||
&act->mtime, &act->atime) == 2) {
|
&act->mtime, &act->atime) == 2) {
|
||||||
act->settime = 1;
|
act->settime = 1;
|
||||||
back->send(backhandle, "", 1);
|
back->send(backhandle, "", 1);
|
||||||
|
@ -4327,7 +4327,7 @@ static void term_out(Terminal *term)
|
|||||||
for (i = 1; i < term->esc_nargs; i++) {
|
for (i = 1; i < term->esc_nargs; i++) {
|
||||||
if (i != 1)
|
if (i != 1)
|
||||||
strcat(term->id_string, ";");
|
strcat(term->id_string, ";");
|
||||||
sprintf(lbuf, "%d", term->esc_args[i]);
|
sprintf(lbuf, "%u", term->esc_args[i]);
|
||||||
strcat(term->id_string, lbuf);
|
strcat(term->id_string, lbuf);
|
||||||
}
|
}
|
||||||
strcat(term->id_string, "c");
|
strcat(term->id_string, "c");
|
||||||
|
@ -5199,8 +5199,8 @@ void write_clip(void *frontend, wchar_t * data, int *attr, int len, int must_des
|
|||||||
multilen = WideCharToMultiByte(CP_ACP, 0, unitab+uindex, 1,
|
multilen = WideCharToMultiByte(CP_ACP, 0, unitab+uindex, 1,
|
||||||
NULL, 0, NULL, NULL);
|
NULL, 0, NULL, NULL);
|
||||||
if (multilen != 1) {
|
if (multilen != 1) {
|
||||||
blen = sprintf(before, "{\\uc%d\\u%d", multilen,
|
blen = sprintf(before, "{\\uc%d\\u%d", (int)multilen,
|
||||||
udata[uindex]);
|
(int)udata[uindex]);
|
||||||
alen = 1; strcpy(after, "}");
|
alen = 1; strcpy(after, "}");
|
||||||
} else {
|
} else {
|
||||||
blen = sprintf(before, "\\u%d", udata[uindex]);
|
blen = sprintf(before, "\\u%d", udata[uindex]);
|
||||||
|
Loading…
Reference in New Issue
Block a user