Fix crash bug with overwriting malloced memory.
authorJeremy Allison <jra@samba.org>
Thu, 7 Nov 2002 22:43:54 +0000 (22:43 +0000)
committerJeremy Allison <jra@samba.org>
Thu, 7 Nov 2002 22:43:54 +0000 (22:43 +0000)
Jeremy.
(This used to be commit 3228730c8311ec6507227f8936318b1d965c1228)

source3/printing/printing.c

index 6d4cc213a74a7de44bee031d86049f9edb23e3bf..71e09c793f6af95a1a96c0b9efd79572d56c0689 100644 (file)
@@ -1111,7 +1111,7 @@ BOOL print_notify_pid_list(const char *printername, TALLOC_CTX *mem_ctx, size_t
        struct tdb_print_db *pdb;
        TDB_DATA data;
        BOOL ret = True;
-       size_t i, num_pids;
+       size_t i, num_pids, offset;
        pid_t *pid_list;
 
        *p_num_pids = 0;
@@ -1141,10 +1141,8 @@ BOOL print_notify_pid_list(const char *printername, TALLOC_CTX *mem_ctx, size_t
                goto done;
        }
 
-       for( i = 0; i < data.dsize; i += 8) {
-               pid_t pid = (pid_t)IVAL(data.dptr, i);
-               pid_list[i] = pid;
-       }
+       for( i = 0, offset = 0; offset < data.dsize; offset += 8, i++)
+               pid_list[i] = (pid_t)IVAL(data.dptr, offset);
 
        *pp_pid_list = pid_list;
        *p_num_pids = num_pids;