]> git.ipfire.org Git - thirdparty/git.git/blobdiff - ssh-upload.c
short i/o: fix calls to read to use xread or read_in_full
[thirdparty/git.git] / ssh-upload.c
index 901e0366df25f23530e68237eabe59891a5b78d7..86b169bf4fb7712327b72d8e57e25248f9572954 100644 (file)
@@ -21,17 +21,14 @@ static int serve_object(int fd_in, int fd_out) {
        ssize_t size;
        unsigned char sha1[20];
        signed char remote;
-       int posn = 0;
-       do {
-               size = read(fd_in, sha1 + posn, 20 - posn);
-               if (size < 0) {
-                       perror("git-ssh-upload: read ");
-                       return -1;
-               }
-               if (!size)
-                       return -1;
-               posn += size;
-       } while (posn < 20);
+
+       size = read_in_full(fd_in, sha1, 20);
+       if (size < 0) {
+               perror("git-ssh-upload: read ");
+               return -1;
+       }
+       if (!size)
+               return -1;
        
        if (verbose)
                fprintf(stderr, "Serving %s\n", sha1_to_hex(sha1));
@@ -54,7 +51,7 @@ static int serve_object(int fd_in, int fd_out) {
 
 static int serve_version(int fd_in, int fd_out)
 {
-       if (read(fd_in, &remote_version, 1) < 1)
+       if (xread(fd_in, &remote_version, 1) < 1)
                return -1;
        write(fd_out, &local_version, 1);
        return 0;
@@ -67,7 +64,7 @@ static int serve_ref(int fd_in, int fd_out)
        int posn = 0;
        signed char remote = 0;
        do {
-               if (posn >= PATH_MAX || read(fd_in, ref + posn, 1) < 1)
+               if (posn >= PATH_MAX || xread(fd_in, ref + posn, 1) < 1)
                        return -1;
                posn++;
        } while (ref[posn - 1]);
@@ -89,7 +86,7 @@ static void service(int fd_in, int fd_out) {
        char type;
        int retval;
        do {
-               retval = read(fd_in, &type, 1);
+               retval = xread(fd_in, &type, 1);
                if (retval < 1) {
                        if (retval < 0)
                                perror("git-ssh-upload: read ");