+2008-01-07 Guillem Jover <guillem@debian.org>
+
+ * dpkg-deb/extract.c (extracthalf): Move negative member length check
+ to ...
+ (parseheaderlength): ... here. Change return type to size_t. Change
+ variable r to ssize_t. Use strtol instead of strtoul to easily catch
+ negative values.
+ * dpkg-deb/info.c (info_spew): Use %zu in a format string instead of
+ %lu to print pathlen, a size_t variable.
+ * dpkg-split/queue.c (do_auto): Change j from unsinged int to int.
+ Cast j to unsigned int when comparing it to i.
+ * lib/varbuf.c (varbufprintf): Change ou from unsigned int to size_t.
+ Change r from unsigned int to int. Cast value compared to r to int.
+ (varbufprintf): Likewise.
+ * src/archives.c (tarobject): Change r from size_t to ssize_t.
+ Cast r to size_t when comparing it to symlinkfn.size.
+ * src/main.c (setforce): Cast string difference to size_t instead of
+ int.
+ * utils/start-stop-daemon.c (parse_schedule): Change str_len from
+ ptrdiff_t to size_t. Cast string difference to size_t instead of
+ ptrdiff_t. Remove ptrdiff_t cast to sizeof.
+
2008-01-07 Guillem Jover <guillem@debian.org>
* scripts/Dpkg/BuildOptions.pm (set): Parse all options separated
and allow overriding its value from the environment. Closes: #458589
* Fix Dpkg::BuildOptions to parse all options in DEB_BUILD_OPTIONS, so
that dpkg-buildpackage called with -j preserves unrecognized options.
+ * Fix several signed vs unsigned value comparisons that were making some
+ code to never be executed.
[ Updated dpkg translations ]
* Norwegian Bokmål (Hans Fredrik Nordhaug). Closes: #457918, #458732
}
}
-static unsigned long parseheaderlength(const char *inh, size_t len,
- const char *fn, const char *what) {
+static size_t
+parseheaderlength(const char *inh, size_t len,
+ const char *fn, const char *what)
+{
char lintbuf[15];
- unsigned long r;
+ ssize_t r;
char *endp;
if (memchr(inh,0,len))
memcpy(lintbuf,inh,len);
lintbuf[len]= ' ';
*strchr(lintbuf,' ')= 0;
- r= strtoul(lintbuf,&endp,10);
+ r = strtol(lintbuf, &endp, 10);
+ if (r < 0)
+ ohshit(_("file `%.250s' is corrupt - negative member length %zi"), fn, r);
if (*endp)
ohshit(_("file `%.250s' is corrupt - bad digit (code %d) in %s"),fn,*endp,what);
- return r;
+ return (size_t)r;
}
void extracthalf(const char *debar, const char *directory,
ohshit(_("file `%.250s' is corrupt - bad magic at end of first header"),debar);
memberlen= parseheaderlength(arh.ar_size,sizeof(arh.ar_size),
debar,"member length");
- if (memberlen<0)
- ohshit(_("file `%.250s' is corrupt - negative member length %zi"),debar,memberlen);
if (!header_done) {
if (memcmp(arh.ar_name,"debian-binary ",sizeof(arh.ar_name)) &&
memcmp(arh.ar_name,"debian-binary/ ",sizeof(arh.ar_name)))
pathlen = strlen(directory) + strlen(component) + 2;
controlfile = (void *) realloc((void *) controlfile, pathlen);
if (!controlfile)
- ohshite(_("realloc failed (%lu bytes)"), pathlen);
+ ohshite(_("realloc failed (%zu bytes)"), pathlen);
memset(controlfile, 0, sizeof(controlfile));
strcat(controlfile, directory);
const char *partfile;
struct partinfo *pi, *refi, *npi, **partlist, *otherthispart;
struct partqueue *pq;
- unsigned int i, j;
- int ap;
+ unsigned int i;
+ int j, ap;
long nr;
FILE *part;
void *buffer;
/* There are still some parts missing. */
for (i=0, ap=0; i<refi->maxpartn; i++)
if (!partlist[i])
- printf("%s%d", !ap++ ? "" : i==j ? _(" and ") : ", ", i+1);
+ printf("%s%d", !ap++ ? "" : i == (unsigned int)j ? _(" and ") : ", ", i + 1);
printf(").\n");
} else {
}
int varbufprintf(struct varbuf *v, const char *fmt, ...) {
- unsigned int ou, r;
+ size_t ou;
+ int r;
va_list al;
ou= v->used;
va_end(al);
if (r < 0) r= (v->size-ou+1) * 2;
v->used= ou+r;
- } while (r >= v->size-ou-1);
+ } while (r >= (int)(v->size - ou - 1));
return r;
}
int varbufvprintf(struct varbuf *v, const char *fmt, va_list va) {
- unsigned int ou, r;
+ size_t ou;
+ int r;
va_list al;
ou= v->used;
r= vsnprintf(v->buf+ou,v->size-ou,fmt,al);
if (r < 0) r= (v->size-ou+1) * 2;
v->used= ou+r;
- } while (r >= v->size-ou-1);
+ } while (r >= (int)(v->size - ou - 1));
return r;
}
struct conffile *conff;
struct tarcontext *tc= (struct tarcontext*)ti->UserData;
int statr, fd, i, existingdirectory, keepexisting;
- size_t r;
+ ssize_t r;
struct stat stab, stabtmp;
char databuf[TARBLKSZ];
struct fileinlist *nifd, **oldnifd;
varbufextend(&symlinkfn);
r= readlink(fnamevb.buf,symlinkfn.buf,symlinkfn.size);
if (r<0) ohshite(_("unable to read link `%.255s'"),ti->Name);
- } while (r == symlinkfn.size);
+ } while ((size_t)r == symlinkfn.size);
symlinkfn.used= r; varbufaddc(&symlinkfn,0);
if (symlink(symlinkfn.buf,fnametmpvb.buf))
ohshite(_("unable to make backup symlink for `%.255s'"),ti->Name);
for (;;) {
comma= strchr(value,',');
- l= comma ? (int)(comma-value) : strlen(value);
+ l = comma ? (size_t)(comma - value) : strlen(value);
for (fip=forceinfos; fip->name; fip++)
if (!strncmp(fip->name,value,l) && strlen(fip->name)==l) break;
if (!fip->name) {
char item_buf[20];
const char *slash;
int count, repeatat;
- ptrdiff_t str_len;
+ size_t str_len;
count = 0;
for (slash = schedule_str; *slash; slash++)
repeatat = -1;
while (schedule_str != NULL) {
slash = strchr(schedule_str,'/');
- str_len = slash ? slash - schedule_str : strlen(schedule_str);
- if (str_len >= (ptrdiff_t)sizeof(item_buf))
+ str_len = slash ? (size_t)(slash - schedule_str) : strlen(schedule_str);
+ if (str_len >= sizeof(item_buf))
badusage("invalid schedule item: far too long"
" (you must delimit items with slashes)");
memcpy(item_buf, schedule_str, str_len);