Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F164165375
D58454.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D58454.diff
View Options
diff --git a/usr.sbin/pkg/config.c b/usr.sbin/pkg/config.c
--- a/usr.sbin/pkg/config.c
+++ b/usr.sbin/pkg/config.c
@@ -31,15 +31,16 @@
#include <sys/utsname.h>
#include <sys/sysctl.h>
+#include <assert.h>
+#include <ctype.h>
#include <dirent.h>
-#include <ucl.h>
#include <err.h>
#include <errno.h>
#include <libutil.h>
#include <paths.h>
#include <stdbool.h>
+#include <ucl.h>
#include <unistd.h>
-#include <ctype.h>
#include "config.h"
@@ -237,12 +238,17 @@
continue;
if (buf != NULL)
memset(buf, 0, bufsz);
+ errno = 0;
rewind(buffp);
+ assert(errno == 0); /* rewinding a memstream never fails */
- for (j = 0; j < strlen(key); ++j)
- fputc(toupper(key[j]), buffp);
- fflush(buffp);
+ for (j = 0; key[j] != '\0'; ++j)
+ if (fputc(toupper(key[j]), buffp) == EOF)
+ err(1, NULL); /* failed to allocate */
+ if (fflush(buffp) != 0)
+ err(1, NULL); /* failed to allocate */
+ assert(buf != NULL);
for (i = 0; i < CONFIG_SIZE; i++) {
if (strcmp(buf, c[i].key) == 0)
break;
diff --git a/usr.sbin/pkg/ecc.c b/usr.sbin/pkg/ecc.c
--- a/usr.sbin/pkg/ecc.c
+++ b/usr.sbin/pkg/ecc.c
@@ -306,7 +306,6 @@
if (oidlen != 1)
return (1);
- ret = -1;
switch (*oid) {
case 0x0a: /* secp256k1 */
ret = import_params(rawparams, &secp256k1_str_params);
@@ -318,12 +317,10 @@
ret = import_params(rawparams, &secp521r1_str_params);
break;
default:
- return (1);
+ ret = -1;
}
- if (ret == 0)
- return (0);
- return (1);
+ return (ret != 0);
}
if (oidlen >= sizeof(oid_brainpoolP) &&
@@ -334,7 +331,6 @@
if (oidlen != 1)
return (1);
- ret = -1;
switch (*oid) {
case 0x07: /* brainpoolP256r1 */
ret = import_params(rawparams, &brainpoolp256r1_str_params);
@@ -361,12 +357,10 @@
ret = import_params(rawparams, &brainpoolp512t1_str_params);
break;
default:
- return (1);
+ ret = -1;
}
- if (ret == 0)
- return (0);
- return (1);
+ return (ret != 0);
}
#ifdef ECC_DEBUG
@@ -526,14 +520,14 @@
int ret;
struct ecc_verify_cbdata cbdata;
- ret = 1;
-
if (sigfile != NULL) {
cbdata.keyfp = fopen(sigfile, "r");
if (cbdata.keyfp == NULL) {
warn("fopen: %s", sigfile);
return (false);
}
+ cbdata.key = NULL;
+ cbdata.keylen = SIZE_MAX;
} else {
cbdata.keyfp = NULL;
cbdata.key = key;
diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c
--- a/usr.sbin/pkg/pkg.c
+++ b/usr.sbin/pkg/pkg.c
@@ -653,6 +653,7 @@
fwrite(line, 1, linelen, tmpfp);
}
+ free(line);
fclose(fp);
fclose(sigfp);
fclose(certfp);
@@ -688,11 +689,11 @@
verify_pubsignature(int fd_pkg, int fd_sig, struct repository *r)
{
struct pubkey *pk;
- char *data;
struct pkgsign_ctx *sctx;
+ const char *pubkey;
+ char *data;
size_t datasz;
bool ret;
- const char *pubkey;
pk = NULL;
sctx = NULL;
@@ -743,8 +744,8 @@
}
/* Verify the signature. */
- printf("Verifying signature with public key %s.a.. ", r->pubkey);
- if (pkgsign_verify_data(sctx, data, datasz, r->pubkey, NULL, 0, pk->sig,
+ printf("Verifying signature with public key %s.a.. ", pubkey);
+ if (pkgsign_verify_data(sctx, data, datasz, pubkey, NULL, 0, pk->sig,
pk->siglen) == false) {
fprintf(stderr, "Signature is not valid\n");
goto cleanup;
@@ -1381,5 +1382,5 @@
execv(pkgpath, __DECONST(char **, pkgargv));
/* NOT REACHED */
- return (EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 30, 7:18 AM (7 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35733486
Default Alt Text
D58454.diff (3 KB)
Attached To
Mode
D58454: pkg: Fix issues raised by clang-analyzer
Attached
Detach File
Event Timeline
Log In to Comment