Use memmove for overlapping regions
authorKen Raeburn <raeburn@mit.edu>
Sun, 15 Oct 2006 07:49:35 +0000 (07:49 +0000)
committerKen Raeburn <raeburn@mit.edu>
Sun, 15 Oct 2006 07:49:35 +0000 (07:49 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18703 dc483132-0cff-0310-8789-dd5450dbe970

src/appl/gssftp/ftp/ftp.c
src/appl/gssftp/ftp/secure.c

index 93ace908871fcadddcf274bd7cb8d57e55446f73..c384f247109f2699aaf0a93d4bfe7e9ae727416a 100644 (file)
@@ -693,35 +693,37 @@ int getreply(int expecteof)
                            n = '5';
                        }
 #ifdef KRB5_KRB4_COMPAT
-                       else if (strcmp(auth_type, "KERBEROS_V4") == 0)
-                               if ((kerror = safe ?
-                                 krb_rd_safe((unsigned char *)ibuf, 
-                                             (unsigned int) len,
-                                             &cred.session,
-                                             &hisctladdr, 
-                                             &myctladdr, &msg_data)
-                               : krb_rd_priv((unsigned char *)ibuf, 
-                                             (unsigned int) len,
-                                             schedule, &cred.session,
-                                             &hisctladdr, &myctladdr,
-                                             &msg_data))
-                               != KSUCCESS) {
-                                 printf("%d reply %s! (krb_rd_%s: %s)\n", code,
-                                       safe ? "modified" : "garbled",
-                                       safe ? "safe" : "priv",
-                                       krb_get_err_text(kerror));
-                                 n = '5';
-                               } else {
-                                 if (debug) printf("%c:", safe ? 'S' : 'P');
-                                 if(msg_data.app_length < sizeof(ibuf) - 2) {
-                                   memcpy(ibuf, msg_data.app_data,
-                                          msg_data.app_length);
+                       else if (strcmp(auth_type, "KERBEROS_V4") == 0) {
+                           if (safe)
+                               kerror = krb_rd_safe((unsigned char *)ibuf,
+                                                    (unsigned int) len,
+                                                    &cred.session,
+                                                    &hisctladdr,
+                                                    &myctladdr, &msg_data);
+                           else
+                               kerror = krb_rd_priv((unsigned char *)ibuf,
+                                                    (unsigned int) len,
+                                                    schedule, &cred.session,
+                                                    &hisctladdr, &myctladdr,
+                                                    &msg_data));
+                           if (kerror != KSUCCESS) {
+                               printf("%d reply %s! (krb_rd_%s: %s)\n", code,
+                                      safe ? "modified" : "garbled",
+                                      safe ? "safe" : "priv",
+                                      krb_get_err_text(kerror));
+                               n = '5';
+                           } else {
+                               if (debug) printf("%c:", safe ? 'S' : 'P');
+                               if(msg_data.app_length < sizeof(ibuf) - 2) {
+                                   memmove(ibuf, msg_data.app_data,
+                                           msg_data.app_length);
                                    strcpy(&ibuf[msg_data.app_length], "\r\n");
-                                 } else {
+                               } else {
                                    printf("Message too long!");
-                                 }
-                                 continue;
                                }
+                               continue;
+                           }
+                       }
 #endif
 #ifdef GSSAPI
                        else if (strcmp(auth_type, "GSSAPI") == 0) {
index 52fda8cac8a16944150355519b6262bf85ad33e0..0998a18e4235362d805e1b8a73541c1e67cb0420 100644 (file)
@@ -404,7 +404,7 @@ int fd;
                                        krb_get_err_text(kerror));
                        return(ERR);
                  }
-                 memcpy(ucbuf, msg_data.app_data, msg_data.app_length);
+                 memmove(ucbuf, msg_data.app_data, msg_data.app_length);
                  nin = bufp = msg_data.app_length;
                }
 #endif /* KRB5_KRB4_COMPAT */