aboutsummaryrefslogtreecommitdiffstats
path: root/src/filelock.c
diff options
context:
space:
mode:
authorPaul Eggert2011-07-27 17:48:01 -0700
committerPaul Eggert2011-07-27 17:48:01 -0700
commit044c22e545acef592ed95e4e3bb9f8aeff67291a (patch)
tree167a4c706b62b12ea979bdf6ad47e70b66bb0394 /src/filelock.c
parentdbf38e02c9ade4979418f24a99962cfef170b957 (diff)
parent8265d3bb30544e58683fc16e23f9908f3d5d0abc (diff)
downloademacs-044c22e545acef592ed95e4e3bb9f8aeff67291a.tar.gz
emacs-044c22e545acef592ed95e4e3bb9f8aeff67291a.zip
Merge: Integer signedness and overflow and related fixes.
Fixes: debbugs:9079
Diffstat (limited to 'src/filelock.c')
-rw-r--r--src/filelock.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/filelock.c b/src/filelock.c
index 18483b6f3f3..c28ee7837fa 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -337,7 +337,7 @@ static int
337lock_file_1 (char *lfname, int force) 337lock_file_1 (char *lfname, int force)
338{ 338{
339 register int err; 339 register int err;
340 intmax_t boot, pid; 340 printmax_t boot, pid;
341 const char *user_name; 341 const char *user_name;
342 const char *host_name; 342 const char *host_name;
343 char *lock_info_str; 343 char *lock_info_str;
@@ -354,15 +354,15 @@ lock_file_1 (char *lfname, int force)
354 else 354 else
355 host_name = ""; 355 host_name = "";
356 lock_info_str = (char *)alloca (strlen (user_name) + strlen (host_name) 356 lock_info_str = (char *)alloca (strlen (user_name) + strlen (host_name)
357 + 2 * INT_STRLEN_BOUND (intmax_t) 357 + 2 * INT_STRLEN_BOUND (printmax_t)
358 + sizeof "@.:"); 358 + sizeof "@.:");
359 pid = getpid (); 359 pid = getpid ();
360 360
361 if (boot) 361 if (boot)
362 sprintf (lock_info_str, "%s@%s.%"PRIdMAX":%"PRIdMAX, 362 sprintf (lock_info_str, "%s@%s.%"pMd":%"pMd,
363 user_name, host_name, pid, boot); 363 user_name, host_name, pid, boot);
364 else 364 else
365 sprintf (lock_info_str, "%s@%s.%"PRIdMAX, 365 sprintf (lock_info_str, "%s@%s.%"pMd,
366 user_name, host_name, pid); 366 user_name, host_name, pid);
367 367
368 err = symlink (lock_info_str, lfname); 368 err = symlink (lock_info_str, lfname);
@@ -542,7 +542,7 @@ lock_file (Lisp_Object fn)
542 register Lisp_Object attack, orig_fn, encoded_fn; 542 register Lisp_Object attack, orig_fn, encoded_fn;
543 register char *lfname, *locker; 543 register char *lfname, *locker;
544 lock_info_type lock_info; 544 lock_info_type lock_info;
545 intmax_t pid; 545 printmax_t pid;
546 struct gcpro gcpro1; 546 struct gcpro gcpro1;
547 547
548 /* Don't do locking while dumping Emacs. 548 /* Don't do locking while dumping Emacs.
@@ -581,9 +581,10 @@ lock_file (Lisp_Object fn)
581 581
582 /* Else consider breaking the lock */ 582 /* Else consider breaking the lock */
583 locker = (char *) alloca (strlen (lock_info.user) + strlen (lock_info.host) 583 locker = (char *) alloca (strlen (lock_info.user) + strlen (lock_info.host)
584 + INT_STRLEN_BOUND (intmax_t) + sizeof "@ (pid )"); 584 + INT_STRLEN_BOUND (printmax_t)
585 + sizeof "@ (pid )");
585 pid = lock_info.pid; 586 pid = lock_info.pid;
586 sprintf (locker, "%s@%s (pid %"PRIdMAX")", 587 sprintf (locker, "%s@%s (pid %"pMd")",
587 lock_info.user, lock_info.host, pid); 588 lock_info.user, lock_info.host, pid);
588 FREE_LOCK_INFO (lock_info); 589 FREE_LOCK_INFO (lock_info);
589 590