Skip to content

Commit 3bf18fb

Browse files
authored
Merge pull request #2039 from mathstuf/various-fixes
Various fixes
2 parents cb0062a + 47428e9 commit 3bf18fb

File tree

6 files changed

+11
-15
lines changed

6 files changed

+11
-15
lines changed

libdispatch/dauth.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@ NC_combinehostport(NCURI* uri)
8383
if(port != NULL) len += (1+strlen(port));
8484
hp = (char*)malloc(len+1);
8585
if(hp == NULL) return NULL;
86-
strncpy(hp,host,len);
87-
if(port != NULL) {
88-
strlcat(hp,":",len+1);
89-
strlcat(hp,port,len+1);
90-
}
86+
snprintf(hp, len+1, "%s%s%s", host, port ? ":" : "", port ? port : "");
9187
return hp;
9288
}
9389

libdispatch/drc.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,7 @@ rcsearch(const char* prefix, const char* rcname, char** pathp)
539539
size_t pathlen = plen+rclen+1+1; /*+1 for '/' +1 for nul */
540540
path = (char*)malloc(pathlen); /* +1 for nul*/
541541
if(path == NULL) {ret = NC_ENOMEM; goto done;}
542-
strncpy(path,prefix,pathlen);
543-
strlcat(path,"/",pathlen);
544-
strlcat(path,rcname,pathlen);
542+
snprintf(path, pathlen, "%s/%s", prefix, rcname);
545543
/* see if file is readable */
546544
f = NCfopen(path,"r");
547545
if(f != NULL)

libdispatch/ncuri.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ ncuriparse(const char* uri0, NCURI** durip)
169169
uri = (char*)malloc(len0+1+1); /* +2 for nul term and for host section terminator */
170170
if(uri == NULL)
171171
{THROW(NC_ENOMEM);}
172-
strncpy(uri,uri0,len0+1);
172+
/* Safe because we allocated enough space right above (and */
173+
/* `strdup` isn't usable because we need "one more char"). */
174+
strcpy(uri,uri0);
173175

174176
/* Walk the uri and do the following:
175177
1. remove leading and trailing whitespace

libsrc/ncx.m4

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ inline static void
304304
swapn2b(void *dst, const void *src, IntType nn)
305305
{
306306
/* it is OK if dst == src */
307-
int i;
307+
IntType i;
308308
uint16_t *op = (uint16_t*) dst;
309309
uint16_t *ip = (uint16_t*) src;
310310
for (i=0; i<nn; i++) {
@@ -393,7 +393,7 @@ swap4b(void *dst, const void *src)
393393
inline static void
394394
swapn4b(void *dst, const void *src, IntType nn)
395395
{
396-
int i;
396+
IntType i;
397397
uint32_t *op = (uint32_t*) dst;
398398
uint32_t *ip = (uint32_t*) src;
399399
for (i=0; i<nn; i++) {
@@ -506,7 +506,7 @@ inline static void
506506
swapn8b(void *dst, const void *src, IntType nn)
507507
{
508508
#ifdef FLOAT_WORDS_BIGENDIAN
509-
int i;
509+
IntType i;
510510
uint64_t *dst_p = (uint64_t*) dst;
511511
uint64_t *src_p = (uint64_t*) src;
512512
for (i=0; i<nn; i++) {
@@ -518,7 +518,7 @@ swapn8b(void *dst, const void *src, IntType nn)
518518
*op = SWAP4(*op);
519519
}
520520
#else
521-
int i;
521+
IntType i;
522522
uint64_t *op = (uint64_t*) dst;
523523
uint64_t *ip = (uint64_t*) src;
524524
for (i=0; i<nn; i++) {

libsrc/v1hpg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ nc_get_NC(NC3_INFO* ncp)
14541454
if(extent > 4096)
14551455
extent = 4096;
14561456
if(extent > filesize)
1457-
extent = filesize;
1457+
extent = (size_t)filesize;
14581458
}
14591459
else if(extent > ncp->chunk)
14601460
extent = ncp->chunk;

libsrc/var.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ out :
512512
*/
513513
int
514514
NC_check_vlen(NC_var *varp, long long vlen_max) {
515-
int ii;
515+
size_t ii;
516516
long long prod=varp->xsz; /* product of xsz and dimensions so far */
517517

518518
assert(varp != NULL);

0 commit comments

Comments
 (0)