Re: Couple of patches



Hello,
> 
> On Thu, 25 Nov 2004, Pavel Tsekov wrote:
> 
> > Hello,
> >
> > I don't like the second hunk of direntry.c.patch.
> >
> > @@ -955,7 +957,7 @@ vfs_s_retrieve_file (struct vfs_class *m
> >         if (got_interrupt ())
> >             goto error_1;
> >
> > -       if (write (handle, buffer, n) < 0) {
> > +       if (write (handle, buffer, n) != n) {
> >             me->verrno = errno;
> >             goto error_1;
> >         }
> >
> > `errno' is not set if write () returns a positive value i.e.
> > less bytes written than in the buffer.

Well, new incarnations with random me->verrno.

-- 
Regards,
Andrew V. Samoilov.
vfs/ChangeLog:

	* direntry.c (vfs_s_open): Fix memory leak.
	(vfs_s_retrieve_file): Check write() return more carefully.

--- direntry.c.sav	Mon Oct 18 13:02:09 2004
+++ direntry.c	Fri Nov 26 13:20:22 2004
@@ -720,8 +720,10 @@ vfs_s_open (struct vfs_class *me, const 
     if ((q = vfs_s_get_path (me, file, &super, 0)) == NULL)
 	return NULL;
     ino = vfs_s_find_inode (me, super, q, LINK_FOLLOW, FL_NONE);
-    if (ino && ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)))
+    if (ino && ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))) {
+	g_free (q);
 	ERRNOR (EEXIST, NULL);
+    }
     if (!ino) {
 	char *dirname, *name, *save;
 	struct vfs_s_entry *ent;
@@ -944,7 +946,7 @@ vfs_s_retrieve_file (struct vfs_class *m
     enable_interrupt_key ();
 
     while ((n = MEDATA->linear_read (me, &fh, buffer, sizeof (buffer)))) {
-
+	int t;
 	if (n < 0)
 	    goto error_1;
 
@@ -955,8 +957,10 @@ vfs_s_retrieve_file (struct vfs_class *m
 	if (got_interrupt ())
 	    goto error_1;
 
-	if (write (handle, buffer, n) < 0) {
-	    me->verrno = errno;
+	t = write (handle, buffer, n);
+	if (t != n) {
+	    if (t == -1)
+		me->verrno = errno;
 	    goto error_1;
 	}
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]