Bläddra i källkod

dpkg-split: Properly check error condition on open when splitting

Guillem Jover 17 år sedan
förälder
incheckning
2a7cbd9bba
1 ändrade filer med 2 tillägg och 1 borttagningar
  1. 2 1
      dpkg-split/split.c

+ 2 - 1
dpkg-split/split.c

@@ -62,7 +62,8 @@ void do_split(const char *const *argv) {
   sprintf(partsizebuf,"%ld",maxpartsize-HEADERALLOWANCE);
   sprintf(partsizebuf,"%ld",maxpartsize-HEADERALLOWANCE);
   sprintf(partsizeallowbuf,"%ld",maxpartsize);
   sprintf(partsizeallowbuf,"%ld",maxpartsize);
   fd= open(sourcefile,O_RDONLY);
   fd= open(sourcefile,O_RDONLY);
-  if (!fd) ohshite(_("unable to open source file `%.250s'"),sourcefile);
+  if (fd < 0)
+    ohshite(_("unable to open source file `%.250s'"), sourcefile);
   if (fstat(fd,&stab)) ohshite(_("unable to fstat source file"));
   if (fstat(fd,&stab)) ohshite(_("unable to fstat source file"));
   if (!S_ISREG(stab.st_mode)) ohshit(_("source file `%.250s' not a plain file"),sourcefile);
   if (!S_ISREG(stab.st_mode)) ohshit(_("source file `%.250s' not a plain file"),sourcefile);
   sprintf(lengthbuf,"%lu",(unsigned long)stab.st_size);
   sprintf(lengthbuf,"%lu",(unsigned long)stab.st_size);